FileSqlServerSync/Server/LocalServer/Program.cs

35 lines
985 B
C#
Raw Normal View History

using LocalServer;
2024-09-05 01:59:57 +00:00
var builder = WebApplication.CreateBuilder(args);
2024-09-05 01:59:57 +00:00
ConfigurationBuilder configurationBuilder = new ();
//添加配置文件路径
configurationBuilder.SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
2024-06-21 04:32:55 +00:00
2024-09-05 01:59:57 +00:00
//加载文件
IConfiguration _configuration = configurationBuilder.Build();
LocalSyncServer.TempRootFile = _configuration["TempDir"]??"C:/TempPack";;
// Add services to the container.
2024-06-21 04:32:55 +00:00
builder.Services.AddControllers();
2024-06-21 04:32:55 +00:00
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<LocalSyncServerFactory>();
2024-06-21 04:32:55 +00:00
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseWebSockets();
app.UseAuthorization();
2024-09-05 01:59:57 +00:00
app.Urls.Clear();
app.Urls.Add("http://0.0.0.0:6818");
app.MapControllers();
2024-06-21 04:32:55 +00:00
app.Run();