From 74c3f8d75ec7d7125b1efb0c22f934eb1ffacc62 Mon Sep 17 00:00:00 2001 From: Joseph Potashnik Date: Sun, 30 Mar 2025 18:25:33 +0100 Subject: [PATCH 1/2] s --- EarleyParserREST/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EarleyParserREST/Program.cs b/EarleyParserREST/Program.cs index d56052e..e462220 100644 --- a/EarleyParserREST/Program.cs +++ b/EarleyParserREST/Program.cs @@ -21,7 +21,7 @@ app.UseCors("AllowAll"); app.UseSwagger(); -app.UseSwaggerUI(); //testing. +app.UseSwaggerUI(); var grammarsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Grammars"); From 81cf0b146fb28985a3defadb19ac9885ac559e68 Mon Sep 17 00:00:00 2001 From: Joseph Potashnik Date: Sun, 30 Mar 2025 18:28:01 +0100 Subject: [PATCH 2/2] print ports --- EarleyParserREST/Program.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/EarleyParserREST/Program.cs b/EarleyParserREST/Program.cs index e462220..f2b2a24 100644 --- a/EarleyParserREST/Program.cs +++ b/EarleyParserREST/Program.cs @@ -1,5 +1,7 @@ using EarleyParser; +using Microsoft.AspNetCore.Hosting.Server.Features; +using Microsoft.AspNetCore.Hosting.Server; var builder = WebApplication.CreateBuilder(args); @@ -27,6 +29,20 @@ var grammarsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Grammars"); var vocsDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Vocs"); +// Print the assigned ports +app.Lifetime.ApplicationStarted.Register(() => +{ + var server = app.Services.GetRequiredService(); + var addresses = server.Features.Get()?.Addresses; + + if (addresses != null) + { + foreach (var address in addresses) + { + Console.WriteLine($"API running at: {address}"); + } + } +}); // Ensure directory exists if (!Directory.Exists(grammarsDirectory))