Download Program.cs from SmartySmile/freespace-freemind: direct link, hf CLI and curl.
- Browser
- Download file 2.57 kB
-
https://huggingface.co/datasets/SmartySmile/freespace-freemind/resolve/main/Program.cs
- Command line
-
hf download hf://datasets/SmartySmile/freespace-freemind/Program.cs
-
curl -L -o Program.cs https://huggingface.co/datasets/SmartySmile/freespace-freemind/resolve/main/Program.cs
2.57 kB
| using PortWatcher.Services; | |
| var builder = WebApplication.CreateBuilder(args); | |
| // Configure Kestrel with explicit HTTPS settings | |
| builder.WebHost.ConfigureKestrel(serverOptions => | |
| { | |
| var httpSettings = builder.Configuration.GetSection("HttpSettings"); | |
| int httpPort = int.TryParse(httpSettings["HttpPort"], out var hp) ? hp : 5293; | |
| int httpsPort = int.TryParse(httpSettings["HttpsPort"], out var hsp) ? hsp : 7145; | |
| serverOptions.Listen(System.Net.IPAddress.Any, httpPort); | |
| serverOptions.Listen(System.Net.IPAddress.Any, httpsPort, | |
| listenOptions => listenOptions.UseHttps()); | |
| }); | |
| // Add services to the container. | |
| builder.Services.AddControllersWithViews(); | |
| builder.Services.AddSession(options => | |
| { | |
| options.IdleTimeout = TimeSpan.FromMinutes(30); | |
| }); | |
| builder.Services.AddScoped<IBenutzerverwaltungService, BenutzerverwaltungService>(); | |
| builder.Services.AddScoped<IPortMonitoringService, PortMonitoringService>(); | |
| builder.Services.AddScoped<IPortAnalysisService, PortAnalysisService>(); | |
| builder.Services.AddScoped<IHttpsCertificateService, HttpsCertificateService>(); | |
| var app = builder.Build(); | |
| // Initialize default admin user on startup | |
| using (var scope = app.Services.CreateScope()) | |
| { | |
| var benutzerverwaltung = scope.ServiceProvider.GetRequiredService<IBenutzerverwaltungService>(); | |
| benutzerverwaltung.InitializeDefaultAdminAsync().Wait(); | |
| // Initialize HTTPS certificate management | |
| var certService = scope.ServiceProvider.GetRequiredService<IHttpsCertificateService>(); | |
| certService.InitializeCertificateAsync().Wait(); | |
| } | |
| // Configure the HTTP request pipeline. | |
| if (!app.Environment.IsDevelopment()) | |
| { | |
| app.UseExceptionHandler("/Home/Error"); | |
| // HSTS: 1 year for production | |
| app.UseHsts(); | |
| } | |
| else | |
| { | |
| // Development: HSTS disabled for development | |
| // HSTS is only for production | |
| } | |
| app.UseHttpsRedirection(); | |
| app.UseStaticFiles(); | |
| app.UseRouting(); | |
| app.UseSession(); | |
| // Middleware zur Authentifizierungsprüfung | |
| app.Use(async (context, next) => | |
| { | |
| var path = context.Request.Path.Value?.ToLower() ?? string.Empty; | |
| var benutzerId = context.Session.GetInt32("BenutzerId"); | |
| if (!path.Contains("/login") && !path.Contains("/anleitung") && benutzerId == null) | |
| { | |
| context.Response.Redirect("/Auth/Login"); | |
| return; | |
| } | |
| await next(); | |
| }); | |
| app.UseAuthorization(); | |
| app.MapControllerRoute( | |
| name: "default", | |
| pattern: "{controller=Home}/{action=Index}/{id?}"); | |
| app.Run(); | |