feat: 为files添加了静态文件服务器管理

master
ArgonarioD 2023-07-06 11:34:14 +08:00
parent 17e86eb214
commit 3812a46e2f
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,7 @@ using System.Text.Json;
using AicsKnowledgeBase_file.Handlers;
using AicsKnowledgeBase_file.Models;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.FileProviders;
Directory.CreateDirectory("./files");
@ -41,6 +42,11 @@ if (app.Environment.IsDevelopment()) {
app.MapGet("/hello", () => "hello");
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new PhysicalFileProvider(Path.Combine(builder.Environment.ContentRootPath, "files")),
RequestPath = "/static"
});
app.UseHttpsRedirection();
app.MapControllers();