generated from microsoft/vscode-remote-try-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
34 lines (25 loc) · 813 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.Urls.Add("http://localhost:5000");
app.MapGet("/", () => "Hello World!");
app.MapGet("/{cityName}/weather", GetWeatherByCity);
app.Run();
Weather GetWeatherByCity(string cityName)
{
app.Logger.LogInformation($"Weather requested for {cityName}.");
var weather = new Weather(cityName);
return weather;
}
public record Weather
{
public string City { get; set; }
public Weather(string city)
{
City = city;
Conditions = "Cloudy";
// Temperature here is in celsius degrees, hence the 0-40 range.
Temperature = new Random().Next(0,40).ToString();
}
public string Conditions { get; set; }
public string Temperature { get; set; }
}