58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using Microsoft.Extensions.Logging.Console;
|
|
using TuringMachine.Server;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Register custom log formatter
|
|
builder.Logging.ClearProviders();
|
|
builder.Logging.AddConsoleFormatter<MinimalConsoleFormatter, ConsoleFormatterOptions>();
|
|
builder.Logging.AddConsole(options => options.FormatterName = "minimal");
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllersWithViews();
|
|
builder.Services.AddRazorPages();
|
|
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseWebAssemblyDebugging();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
|
// app.UseHsts();
|
|
}
|
|
|
|
// app.UseHttpsRedirection();
|
|
|
|
app.UseBlazorFrameworkFiles();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
app.MapRazorPages();
|
|
app.MapControllers();
|
|
app.MapFallbackToFile("index.html");
|
|
|
|
|
|
// Open browser on startup for standalone execution
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.Lifetime.ApplicationStarted.Register(() =>
|
|
{
|
|
try
|
|
{
|
|
var url = app.Urls.FirstOrDefault()?.Replace("0.0.0.0", "localhost") ?? "http://localhost:11100";
|
|
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url) { UseShellExecute = true });
|
|
}
|
|
catch { }
|
|
});
|
|
}
|
|
|
|
app.Run();
|