send console data to gotify
This commit is contained in:
parent
e014128ddc
commit
41811ef2c0
@ -6,7 +6,7 @@ using WeatherDashboard;
|
|||||||
|
|
||||||
var builder = Host.CreateDefaultBuilder(args);
|
var builder = Host.CreateDefaultBuilder(args);
|
||||||
|
|
||||||
builder.ConfigureAppConfiguration((context, config) =>
|
builder.ConfigureAppConfiguration((context, config) =>
|
||||||
{
|
{
|
||||||
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ builder.ConfigureAppConfiguration((context, config) =>
|
|||||||
config.AddJsonFile($"appsettings.{environment}.json", true);
|
config.AddJsonFile($"appsettings.{environment}.json", true);
|
||||||
});
|
});
|
||||||
|
|
||||||
builder.ConfigureServices(services =>
|
builder.ConfigureServices(services =>
|
||||||
{
|
{
|
||||||
services.AddHttpClient();
|
services.AddHttpClient();
|
||||||
});
|
});
|
||||||
@ -27,7 +27,13 @@ var httpClientFactory = app.Services.GetService<IHttpClientFactory>();
|
|||||||
|
|
||||||
var httpClient = httpClientFactory.CreateClient();
|
var httpClient = httpClientFactory.CreateClient();
|
||||||
var apiUrl = configuration["ApiUrl"];
|
var apiUrl = configuration["ApiUrl"];
|
||||||
|
var gotifyUrl = configuration["GotifyUrl"];
|
||||||
|
|
||||||
var weatherSet = await httpClient.GetFromJsonAsync<WeatherSet>(apiUrl);
|
var weatherSet = await httpClient.GetFromJsonAsync<WeatherSet>(apiUrl);
|
||||||
|
|
||||||
Console.WriteLine(weatherSet.Current.ConditionName);
|
var notificationResponse = await httpClient.PostAsJsonAsync(gotifyUrl, new
|
||||||
|
{
|
||||||
|
title = "Weather Conditions",
|
||||||
|
message = $"{weatherSet.Current.ConditionName} and {weatherSet.Current.Temperature} degrees",
|
||||||
|
priority = 5
|
||||||
|
});
|
@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
"ApiUrl": "https://weather.binarydad.com/api"
|
"ApiUrl": "https://weather.binarydad.com/api",
|
||||||
|
"GotifyUrl": "https://push.binarydad.com/message?token=AaYB_oOYlFz1nnp"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user