From db999a53b8833d56b5e6ddb846fe4aaa7dbb0881 Mon Sep 17 00:00:00 2001 From: SEAN Date: Wed, 3 Dec 2025 15:04:17 +0900 Subject: [PATCH] =?UTF-8?q?[=E2=9C=A8]=20Front=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SPMS_API/Program.cs | 52 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/SPMS_API/Program.cs b/SPMS_API/Program.cs index d5e0ef3..7109b79 100644 --- a/SPMS_API/Program.cs +++ b/SPMS_API/Program.cs @@ -1,7 +1,13 @@ -var builder = WebApplication.CreateBuilder(args); -// Add services to the container. -// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi + +var builder = WebApplication.CreateBuilder(new WebApplicationOptions +{ + WebRootPath = Environment.GetEnvironmentVariable("ASPNETCORE_WEBROOT") + ?? "wwwroot" +}); + + +builder.Services.AddControllers(); builder.Services.AddOpenApi(); var app = builder.Build(); @@ -11,31 +17,23 @@ if (app.Environment.IsDevelopment()) { app.MapOpenApi(); } +var webRoot = app.Environment.WebRootPath; +Console.WriteLine($"[System] Web Root Path: {webRoot}"); // 로그에 경로 찍어보기 + +if (Directory.Exists(webRoot)) +{ + app.UseStaticFiles(); // 경로가 있으면 파일 서빙 +} +else +{ + Console.WriteLine("[Error] Web root folder not found!"); +} app.UseHttpsRedirection(); +app.UseRouting(); -var summaries = new[] -{ - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" -}; +// [4] 요청 처리 +app.MapControllers(); +app.MapFallbackToFile("index.html"); -app.MapGet("/weatherforecast", () => - { - var forecast = Enumerable.Range(1, 5).Select(index => - new WeatherForecast - ( - DateOnly.FromDateTime(DateTime.Now.AddDays(index)), - Random.Shared.Next(-20, 55), - summaries[Random.Shared.Next(summaries.Length)] - )) - .ToArray(); - return forecast; - }) - .WithName("GetWeatherForecast"); - -app.Run(); - -record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary) -{ - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); -} \ No newline at end of file +app.Run(); \ No newline at end of file