Skip to content

Commit

Permalink
adding sync endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
EarliestFall988 committed Nov 18, 2023
1 parent b02f790 commit dc4d29a
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 11 deletions.
27 changes: 16 additions & 11 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,28 @@

var builder = WebApplication.CreateBuilder(args);

var appsetting = new ConfigurationBuilder()
var env = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build();

var splash = "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n <meta charset=\"utf-8\" />\r\n <title>It Works!!</title>\r\n <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">\r\n <link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>\r\n <link href=\"https://fonts.googleapis.com/css2?family=Roboto&display=swap\" rel=\"stylesheet\">\r\n</head>\r\n<style>\r\n .body {\r\n background-color: #171717;\r\n width: 90vw;\r\n height: 90vh;\r\n color: #ffffff;\r\n padding: 3rem;\r\n font-family: 'Roboto', sans-serif;\r\n display: block;\r\n box-sizing: border-box;\r\n }\r\n\r\n h1 {\r\n font-size: 3rem;\r\n }\r\n\r\n p {\r\n font-size: 1.25rem;\r\n }\r\n\r\n a {\r\n font-size: 1.25rem;\r\n color: #ffff;\r\n text-decoration: none;\r\n background-color: #1d4ed8;\r\n padding: 0.25rem;\r\n border-radius: 0.25rem;\r\n }\r\n\r\n</style>\r\n<body class=\"body\">\r\n <h1>It Works!</h1>\r\n <p>Copy the link in your browser and paste it back in the Valkyrie Connection Page</p>\r\n <p>or</p>\r\n <a href=\"/api/v1/sync\">Sync Manually</a>\r\n</body>\r\n</html>";

// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

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())
{
Expand All @@ -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"));
});


Expand Down
46 changes: 46 additions & 0 deletions splash.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>It Works!!</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
</head>
<style>
.body {
background-color: #171717;
width: 90vw;
height: 90vh;
color: #ffffff;
padding: 3rem;
font-family: 'Roboto', sans-serif;
display: block;
box-sizing: border-box;
}

h1 {
font-size: 3rem;
}

p {
font-size: 1.25rem;
}

a {
font-size: 1.25rem;
color: #ffff;
text-decoration: none;
background-color: #1d4ed8;
padding: 0.25rem;
border-radius: 0.25rem;
}

</style>
<body class="body">
<h1>It Works!</h1>
<p>Copy the link in your browser and paste it back in the Valkyrie Connection Page</p>
<p>or</p>
<a href="/sync">Sync Manually</a>
</body>
</html>

0 comments on commit dc4d29a

Please sign in to comment.