WeatherDashboard/WeatherDashboard.Console/Program.cs

25 lines
600 B
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureAppConfiguration(config =>
{
config.AddJsonFile("settings.json");
});
builder.ConfigureServices(services =>
{
services.AddHttpClient();
});
var app = builder.Build();
var configuration = app.Services.GetService<IConfiguration>();
var httpClientFactory = app.Services.GetService<IHttpClientFactory>();
var httpClient = httpClientFactory.CreateClient();
var apiUrl = configuration["ApiUrl"];