New Project
Ani 폴더 리스트 가져오는 API
This commit is contained in:
37
VideoArchiveAPI/Program.cs
Normal file
37
VideoArchiveAPI/Program.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using VideoArchiveAPI;
|
||||
|
||||
string configPath = "config.json";
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// configPath <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
configPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), configPath);
|
||||
|
||||
if (!System.IO.File.Exists(configPath))
|
||||
{
|
||||
string defaultSetting = "{\"Config\": {\"Port\": 8981,\"Location\": \".\\\\\"}}";
|
||||
System.IO.File.WriteAllText(configPath , defaultSetting);
|
||||
|
||||
|
||||
}
|
||||
|
||||
builder.Configuration.AddJsonFile(configPath, optional: false, reloadOnChange: true);
|
||||
builder.Services.Configure<Config>(builder.Configuration.GetSection("Config"));
|
||||
Config localConfig = builder.Configuration.GetSection(Config.SectionName).Get<Config>();
|
||||
|
||||
builder.WebHost.ConfigureKestrel((context, serverOptions) =>
|
||||
{
|
||||
serverOptions.Listen(IPAddress.Loopback, localConfig.Port);
|
||||
});
|
||||
|
||||
builder.Services.AddControllers();
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
Reference in New Issue
Block a user