diff --git a/EarleyParserREST/Program.cs b/EarleyParserREST/Program.cs index d56052e..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); @@ -21,12 +23,26 @@ app.UseCors("AllowAll"); app.UseSwagger(); -app.UseSwaggerUI(); //testing. +app.UseSwaggerUI(); 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))