Intialize API project.
This commit is contained in:
parent
3b25f390c4
commit
ef6adf0823
53
.gitignore
vendored
Normal file
53
.gitignore
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Build results
|
||||||
|
bin/
|
||||||
|
obj/
|
||||||
|
out/
|
||||||
|
|
||||||
|
# .NET user-specific files
|
||||||
|
*.user
|
||||||
|
*.rsuser
|
||||||
|
*.suo
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# VS Code
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
# Visual Studio
|
||||||
|
.vs/
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# ASP.NET secrets
|
||||||
|
secrets.json
|
||||||
|
|
||||||
|
# Publish output
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# NuGet
|
||||||
|
*.nupkg
|
||||||
|
*.snupkg
|
||||||
|
.nuget/
|
||||||
|
packages/
|
||||||
|
|
||||||
|
# Test results
|
||||||
|
TestResults/
|
||||||
|
*.trx
|
||||||
|
|
||||||
|
# Coverage
|
||||||
|
coverage/
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# Temporary files
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
38
Controllers/WeatherForecastController.fs
Normal file
38
Controllers/WeatherForecastController.fs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
namespace MusicAPI.Controllers
|
||||||
|
|
||||||
|
open System
|
||||||
|
open System.Collections.Generic
|
||||||
|
open System.Linq
|
||||||
|
open System.Threading.Tasks
|
||||||
|
open Microsoft.AspNetCore.Mvc
|
||||||
|
open Microsoft.Extensions.Logging
|
||||||
|
open MusicAPI
|
||||||
|
|
||||||
|
[<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)] }
|
||||||
|
|]
|
||||||
13
MusicAPI.fsproj
Normal file
13
MusicAPI.fsproj
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="WeatherForecast.fs" />
|
||||||
|
<Compile Include="Controllers/WeatherForecastController.fs" />
|
||||||
|
<Compile Include="Program.fs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
36
Program.fs
Normal file
36
Program.fs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
namespace MusicAPI
|
||||||
|
#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.AspNetCore.HttpsPolicy
|
||||||
|
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.UseHttpsRedirection()
|
||||||
|
|
||||||
|
app.UseAuthorization()
|
||||||
|
app.MapControllers()
|
||||||
|
|
||||||
|
app.Run()
|
||||||
|
|
||||||
|
exitCode
|
||||||
25
Properties/launchSettings.json
Normal file
25
Properties/launchSettings.json
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/launchsettings.json",
|
||||||
|
"profiles": {
|
||||||
|
"http": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "weatherforecast",
|
||||||
|
"applicationUrl": "http://localhost:5006",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"https": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "weatherforecast",
|
||||||
|
"applicationUrl": "https://localhost:7072;http://localhost:5006",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
README.md
10
README.md
@ -1,3 +1,11 @@
|
|||||||
# MusicAPI
|
# MusicAPI
|
||||||
|
|
||||||
F# music API for offline server.
|
## .NET commands
|
||||||
|
|
||||||
|
initialize project:
|
||||||
|
* `dotnet new webapi -lang F# -o MusicAPI`
|
||||||
|
|
||||||
|
run project locally:
|
||||||
|
* `dotnet run`
|
||||||
|
|
||||||
|
## Deployment
|
||||||
|
|||||||
11
WeatherForecast.fs
Normal file
11
WeatherForecast.fs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace MusicAPI
|
||||||
|
|
||||||
|
open System
|
||||||
|
|
||||||
|
type WeatherForecast =
|
||||||
|
{ Date: DateTime
|
||||||
|
TemperatureC: int
|
||||||
|
Summary: string }
|
||||||
|
|
||||||
|
member this.TemperatureF =
|
||||||
|
32.0 + (float this.TemperatureC / 0.5556)
|
||||||
8
appsettings.Development.json
Normal file
8
appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
appsettings.json
Normal file
9
appsettings.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user