FileSqlServerSync/Server/RemoteServer/Program.cs

43 lines
1.1 KiB
C#
Raw Normal View History

using Microsoft.EntityFrameworkCore;
using RemoteServer;
using RemoteServer.Models;
2024-06-21 04:32:55 +00:00
var builder = WebApplication.CreateBuilder(args);
ConfigurationBuilder configurationBuilder = new();
2024-06-21 04:32:55 +00:00
// Add services to the container.
//添加配置文件路径
configurationBuilder
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json");
//加载文件
IConfiguration _configuration = configurationBuilder.Build();
RemoteSyncServer.TempRootFile = _configuration["TempDir"] ?? "C:/TempPack";
;
2024-06-21 04:32:55 +00:00
builder.Services.AddControllers();
builder.Services.AddDbContext<SqliteDbContext>(opions =>
{
opions.UseSqlite(builder.Configuration.GetConnectionString("DbPath"));
});
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();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
2024-09-05 01:59:57 +00:00
app.UseWebSockets();
app.Urls.Clear();
app.Urls.Add("http://0.0.0.0:6818");
2024-06-21 04:32:55 +00:00
app.MapControllers();
app.Run();