2 ms·
Some C# code to create a minimal web application: var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.UseHttpsRedirection(); va
by DeathArrow 4y ago
Some C# code to create a minimal web application:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseHttpsRedirection();
var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateTime.Now.AddDays(index),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast");
app.Run();
internal record WeatherForecast(DateTime Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
- hombre_fatal 4y agoIf you’re going to post irrelevant code, at least format it.
- DeathArrow 4y agoI posted it to illustrate what in most languages you can do trivial apps with a few lines of code, so Lisp does not hold an advantage here. It's hard to format code on phone, sorry about that.