cs-codex-dist-tests/Tools/AutoClientCenter/Program.cs

44 lines
1.1 KiB
C#
Raw Normal View History

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();
}
}
}