配置静态文件与首页路径
This commit is contained in:
parent
f171251921
commit
4c6b9b567a
|
|
@ -81,7 +81,12 @@ public static class Program
|
|||
options.GetLevel = (httpContext, elapsed, ex) => LogEventLevel.Information;
|
||||
});
|
||||
app.MapControllers();
|
||||
// app.MapGet("/", () => "Hello World!");
|
||||
// 添加根目录映射
|
||||
app.MapGet("/", async context =>
|
||||
{
|
||||
context.Response.ContentType = "text/html";
|
||||
await context.Response.SendFileAsync(Path.Combine(app.Environment.WebRootPath, "index.html"));
|
||||
});
|
||||
// if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
|
|
@ -97,6 +102,10 @@ public static class Program
|
|||
Log.Logger.Information("ApplicationStarted");
|
||||
CodeFirst.InitTable();
|
||||
});
|
||||
|
||||
// 启用静态文件支持
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseCors("AllowAny");
|
||||
app.Run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue