From dc4d29a5cc37389f6ac674c8f789e631ac494e40 Mon Sep 17 00:00:00 2001 From: Taylor Howell Date: Sat, 18 Nov 2023 16:46:24 -0600 Subject: [PATCH] adding sync endpoint --- Program.cs | 27 ++++++++++++++++----------- splash.html | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 splash.html diff --git a/Program.cs b/Program.cs index 9799891..fa1f55f 100644 --- a/Program.cs +++ b/Program.cs @@ -9,11 +9,13 @@ var builder = WebApplication.CreateBuilder(args); -var appsetting = new ConfigurationBuilder() +var env = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); +var splash = "\r\n\r\n\r\n \r\n It Works!!\r\n \r\n \r\n \r\n\r\n\r\n\r\n

It Works!

\r\n

Copy the link in your browser and paste it back in the Valkyrie Connection Page

\r\n

or

\r\n Sync Manually\r\n\r\n"; + // Add services to the container. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); @@ -21,17 +23,14 @@ var app = builder.Build(); -var apiKey = appsetting["API_KEY"]; +var apiKey = env["API_KEY"]; var valkApiKey = "some key"; -Debug.WriteLine("\napi key: " + apiKey + "\n"); - long minuteCountWaitTime = 5; StateMachinesController? stateMachinesController = new StateMachinesController(minuteCountWaitTime); - // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { @@ -40,19 +39,25 @@ } - app.UseHttpsRedirection(); -var summaries = new[] -{ - "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" -}; +//var summaries = new[] +//{ +// "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" +//}; app.MapGet("/", (HttpContext ctx) => +{ + ctx.Response.Headers.Add("Content-Type", "text/html"); + ctx.Response.StatusCode = 200; + return splash; +}); + +app.MapGet("/api/v1/sync", (HttpContext ctx) => { ctx.Response.Headers.Add("Content-Type", "application/json"); ctx.Response.StatusCode = 200; - return JsonSerializer.Serialize(new message("Hello World!")); + return JsonSerializer.Serialize(new message("Syncing")); }); diff --git a/splash.html b/splash.html new file mode 100644 index 0000000..f0d80ef --- /dev/null +++ b/splash.html @@ -0,0 +1,46 @@ + + + + + It Works!! + + + + + + +

It Works!

+

Copy the link in your browser and paste it back in the Valkyrie Connection Page

+

or

+ Sync Manually + + \ No newline at end of file