-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
34 lines (29 loc) · 1.09 KB
/
Program.cs
File metadata and controls
34 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System.Diagnostics;
using System.Runtime.InteropServices;
using Qubic.ScTester;
using Qubic.ScTester.Components;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
builder.Services.AddSingleton<ContractDiscovery>();
builder.Services.AddScoped<ScQueryService>();
builder.WebHost.UseUrls("http://127.0.0.1:0");
var app = builder.Build();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
app.Lifetime.ApplicationStarted.Register(() =>
{
var address = app.Urls.FirstOrDefault() ?? "http://localhost:5050";
Console.WriteLine($"Qubic SC Tester running at {address}");
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Process.Start(new ProcessStartInfo(address) { UseShellExecute = true });
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Process.Start("open", address);
else
Process.Start("xdg-open", address);
}
catch { /* Browser auto-open is best-effort */ }
});
app.Run();