[] Front 연결
All checks were successful
SPMS_API/pipeline/head This commit looks good

This commit is contained in:
SEAN 2025-12-03 15:04:17 +09:00
parent b2e022a685
commit db999a53b8

View File

@ -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);
}
app.Run();