ppcsignals/TxtViz
0
1var builder = WebApplication.CreateBuilder(args);
2
3// 1. Add services to the container.
4builder.Services.AddRazorPages(); // For .cshtml pages
5builder.Services.AddControllers(); // For the API (Chart data)
6
7builder.Services.AddControllers().AddJsonOptions(options =>
8{
9 options.JsonSerializerOptions.PropertyNamingPolicy = null;
10 options.JsonSerializerOptions.MaxDepth = 0;
11 options.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
12 options.JsonSerializerOptions.WriteIndented = true;
13
14});
15
16var app = builder.Build();
17
18// 2. Configure the HTTP request pipeline.
19if (!app.Environment.IsDevelopment())
20{
21 app.UseExceptionHandler("/Error");
22 app.UseHsts();
23}
24
25app.UseHttpsRedirection();
26app.UseStaticFiles(); // Serves CSS/JS from wwwroot
27
28app.UseRouting();
29
30app.UseAuthorization();
31
32// 3. Map the endpoints
33app.MapRazorPages(); // Maps Pages/Index.cshtml to "/"
34app.MapControllers(); // Maps api/chartdata
35
36app.Run();