Program.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace Yunda.SOMS.DataMonitoringServer.Service
  2. {
  3. public class Program
  4. {
  5. public static void Main(string[] args)
  6. {
  7. var builder = WebApplication.CreateBuilder(args);
  8. // Add services to the container.
  9. builder.Services.AddAuthorization();
  10. var app = builder.Build();
  11. // Configure the HTTP request pipeline.
  12. app.UseAuthorization();
  13. var summaries = new[]
  14. {
  15. "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
  16. };
  17. //app.UseSwagger();
  18. //app.UseSwaggerUI();
  19. app.MapGet("/weatherforecast", (HttpContext httpContext) =>
  20. {
  21. var forecast = Enumerable.Range(1, 5).Select(index =>
  22. new WeatherForecast
  23. {
  24. Date = DateTime.Now.AddDays(index),
  25. TemperatureC = Random.Shared.Next(-20, 55),
  26. Summary = summaries[Random.Shared.Next(summaries.Length)]
  27. })
  28. .ToArray();
  29. return forecast;
  30. });
  31. app.Run();
  32. }
  33. }
  34. }