From c69c98662c13b0ec9fc5e7d2bcdba43761f0c959 Mon Sep 17 00:00:00 2001 From: FunctionsAPI Date: Sun, 19 Jan 2025 13:51:33 +0000 Subject: [PATCH] Automatic push from FunctionsAPI --- Program.cs | 39 +++++++++++++++++++++++++++++++++++++++ README.md | 3 +-- Startup.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ main.csproj | 8 ++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 Program.cs create mode 100644 Startup.cs create mode 100644 main.csproj diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..5b78f7c --- /dev/null +++ b/Program.cs @@ -0,0 +1,39 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +using System; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace main +{ + public class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) + { + string port = Environment.GetEnvironmentVariable("PORT") ?? "8080"; + string url = String.Concat("http://0.0.0.0:", port); + + return Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup().UseUrls(url); + }); + } + } +} diff --git a/README.md b/README.md index a26729d..19cb287 100644 --- a/README.md +++ b/README.md @@ -1,2 +1 @@ -# samples - +# dotnet hello-world diff --git a/Startup.cs b/Startup.cs new file mode 100644 index 0000000..fdc30ca --- /dev/null +++ b/Startup.cs @@ -0,0 +1,42 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace main +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseRouting(); + + app.UseEndpoints(endpoints => + { + endpoints.MapGet("/", async context => + { + await context.Response.WriteAsync("hello, world"); + }); + }); + } + } +} diff --git a/main.csproj b/main.csproj new file mode 100644 index 0000000..7af71f2 --- /dev/null +++ b/main.csproj @@ -0,0 +1,8 @@ + + + + netcoreapp3.1 + main + + +