初始化
This commit is contained in:
38
WebApplication3/Controllers/WeatherForecastController.fs
Normal file
38
WebApplication3/Controllers/WeatherForecastController.fs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace WebApplication3.Controllers
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.Linq
|
||||
open System.Threading.Tasks
|
||||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.Extensions.Logging
|
||||
open WebApplication3
|
||||
|
||||
[<ApiController>]
|
||||
[<Route("[controller]")>]
|
||||
type WeatherForecastController (logger : ILogger<WeatherForecastController>) =
|
||||
inherit ControllerBase()
|
||||
|
||||
let summaries =
|
||||
[|
|
||||
"Freezing"
|
||||
"Bracing"
|
||||
"Chilly"
|
||||
"Cool"
|
||||
"Mild"
|
||||
"Warm"
|
||||
"Balmy"
|
||||
"Hot"
|
||||
"Sweltering"
|
||||
"Scorching"
|
||||
|]
|
||||
|
||||
[<HttpGet>]
|
||||
member _.Get() =
|
||||
let rng = System.Random()
|
||||
[|
|
||||
for index in 0..4 ->
|
||||
{ Date = DateTime.Now.AddDays(float index)
|
||||
TemperatureC = rng.Next(-20,55)
|
||||
Summary = summaries.[rng.Next(summaries.Length)] }
|
||||
|]
|
||||
34
WebApplication3/Program.fs
Normal file
34
WebApplication3/Program.fs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace WebApplication3
|
||||
#nowarn "20"
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open System.IO
|
||||
open System.Linq
|
||||
open System.Threading.Tasks
|
||||
open Microsoft.AspNetCore
|
||||
open Microsoft.AspNetCore.Builder
|
||||
open Microsoft.AspNetCore.Hosting
|
||||
open Microsoft.Extensions.Configuration
|
||||
open Microsoft.Extensions.DependencyInjection
|
||||
open Microsoft.Extensions.Hosting
|
||||
open Microsoft.Extensions.Logging
|
||||
|
||||
module Program =
|
||||
let exitCode = 0
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
|
||||
let builder = WebApplication.CreateBuilder(args)
|
||||
|
||||
builder.Services.AddControllers()
|
||||
|
||||
let app = builder.Build()
|
||||
|
||||
|
||||
app.UseAuthorization()
|
||||
app.MapControllers()
|
||||
|
||||
app.Run()
|
||||
|
||||
exitCode
|
||||
31
WebApplication3/Properties/launchSettings.json
Normal file
31
WebApplication3/Properties/launchSettings.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:63246",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"applicationUrl": "http://localhost:5149",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
WebApplication3/WeatherForecast.fs
Normal file
11
WebApplication3/WeatherForecast.fs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace WebApplication3
|
||||
|
||||
open System
|
||||
|
||||
type WeatherForecast =
|
||||
{ Date: DateTime
|
||||
TemperatureC: int
|
||||
Summary: string }
|
||||
|
||||
member this.TemperatureF =
|
||||
32.0 + (float this.TemperatureC / 0.5556)
|
||||
13
WebApplication3/WebApplication3.fsproj
Normal file
13
WebApplication3/WebApplication3.fsproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="WeatherForecast.fs" />
|
||||
<Compile Include="Controllers/WeatherForecastController.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
8
WebApplication3/appsettings.Development.json
Normal file
8
WebApplication3/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
WebApplication3/appsettings.json
Normal file
9
WebApplication3/appsettings.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
Reference in New Issue
Block a user