// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapGet("/", async context => { CurrentWeatherClient currentWeather = new CurrentWeatherClient(new System.Net.Http.HttpClient(), "https://api.openweathermap.org/data/2.5/weather", "d7432f95eff46ab9d1047f641430710f"); WeatherLoad weatherLoad; weatherLoad = await currentWeather.Get("London"); //CurrentWeatherResponse currentWeatherResponse; //currentWeatherResponse = await currentWeather.Get("London"); await context.Response.WriteAsync("Hello World!"); await context.Response.WriteAsync(weatherLoad.WeatherReadings[0].Temperature_C.ToString()); //await context.Response.WriteAsync(currentWeatherResponse.Main.Temperature.ToString()); }); }); }
static async Task <API.Weather.Model.WeatherLoad> GetCurrentWeather(string url, string accessKey, string city) { CurrentWeatherClient currentWeather = new API.Weather.OpenWeatherMap.CurrentWeatherClient(new System.Net.Http.HttpClient(), url, accessKey); var result = await currentWeather.Get("London"); return(result); }