2024-09-11 10:08:06 +00:00
|
|
|
|
|
|
|
namespace AutoClientCenter
|
|
|
|
{
|
|
|
|
public class Program
|
|
|
|
{
|
|
|
|
public static void Main(string[] args)
|
|
|
|
{
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
2024-09-11 12:06:48 +00:00
|
|
|
var listenPort = Environment.GetEnvironmentVariable("APIPORT");
|
|
|
|
if (string.IsNullOrEmpty(listenPort)) listenPort = "31090";
|
|
|
|
|
|
|
|
builder.WebHost.ConfigureKestrel((context, options) =>
|
|
|
|
{
|
|
|
|
options.ListenAnyIP(Convert.ToInt32(listenPort));
|
|
|
|
});
|
|
|
|
|
2024-09-11 10:08:06 +00:00
|
|
|
builder.Services.AddSingleton<ITaskService>(new TaskService());
|
|
|
|
builder.Services.AddControllers();
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
2024-09-11 12:06:48 +00:00
|
|
|
Console.WriteLine("AutoClientCenter listening on port " + listenPort);
|
|
|
|
|
2024-09-11 10:08:06 +00:00
|
|
|
app.Run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|