This commit is contained in:
caleb 2025-07-06 23:45:45 +09:00
parent fd0dd2b18e
commit 7765f84b03
4 changed files with 55 additions and 33 deletions

29
.editorconfig Normal file
View File

@ -0,0 +1,29 @@
root = true
# All files
[*]
indent_style = space
# Xml files
[*.xml]
indent_size = 2
[*.fs]
fsharp_space_before_uppercase_invocation = true
# Write a comment by starting the line with a '#'
[*.{fs,fsx,fsi}]
fsharp_bar_before_discriminated_union_declaration = true
max_line_length = 120
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4
tab_width = 4
# New line preferences
insert_final_newline = false

View File

@ -12,27 +12,19 @@ module Client =
// and refresh your browser, no need to recompile unless you add or remove holes.
type IndexTemplate = Template<"wwwroot/index.html", ClientLoad.FromDocument>
let People =
ListModel.FromSeq [
"John"
"Paul"
]
let People = ListModel.FromSeq [ "John"; "Paul" ]
[<SPAEntryPoint>]
let Main () =
let newName = Var.Create ""
IndexTemplate.Main()
.ListContainer(
People.View.DocSeqCached(fun (name: string) ->
IndexTemplate.ListItem().Name(name).Doc()
)
)
IndexTemplate
.Main()
.ListContainer(People.View.DocSeqCached (fun (name: string) -> IndexTemplate.ListItem().Name(name).Doc ()))
.Name(newName)
.Add(fun _ ->
People.Add(newName.Value)
newName.Value <- ""
)
.Doc()
People.Add newName.Value
newName.Value <- "")
.Doc ()
|> Doc.RunById "main"

View File

@ -8,33 +8,34 @@ open web_api_cookbook
[<EntryPoint>]
let main args =
let builder = WebApplication.CreateBuilder(args)
let builder = WebApplication.CreateBuilder (args)
// Add services to the container.
builder.Services.AddWebSharper()
.AddAuthentication("WebSharper")
.AddCookie("WebSharper", fun options -> ())
builder.Services.AddWebSharper().AddAuthentication("WebSharper").AddCookie ("WebSharper", fun options -> ())
|> ignore
let app = builder.Build()
let app = builder.Build ()
// Configure the HTTP request pipeline.
if not (app.Environment.IsDevelopment()) then
app.UseExceptionHandler("/Error")
if not (app.Environment.IsDevelopment ()) then
app
.UseExceptionHandler("/Error")
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
.UseHsts()
.UseHsts ()
|> ignore
app.UseHttpsRedirection()
#if DEBUG
app
.UseHttpsRedirection()
#if DEBUG
.UseWebSharperScriptRedirect(startVite = true)
#endif
.UseDefaultFiles()
.UseStaticFiles()
//Enable if you want to make RPC calls to server
//.UseWebSharperRemoting()
|> ignore
app.Run()
.UseHttpsRedirection ()
//Enable if you want to make RPC calls to server
//.UseWebSharperRemoting()
|> ignore
app.Run ()
0 // Exit code

View File

@ -3,4 +3,4 @@
"UseDownloadedResources": false,
"DebugScriptRedirectUrl": "http://localhost:56440"
}
}
}