File tree Expand file tree Collapse file tree 13 files changed +755
-19
lines changed Expand file tree Collapse file tree 13 files changed +755
-19
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1- module Safe
1+ module Flask.App
22
33open Fable.Python .Builtins
4- open Flask
4+ open Fable.Python .Flask
5+ open Feliz.ViewEngine
56
6- let app = Flask(__ name__)
7- let index = app.route( " /" )
7+ let app = Flask.Create(__ name__, " /public" )
88
9- let a = builtins.len
9+ let htmlPage page =
10+ page |> Render.htmlDocument
1011
11- let hello_world () =
12- " <p>Hello, World!</p>"
13- //flask.render_template()
1412
15- hello_ world |> index |> ignore
13+ let site : Site = {
14+ Title= " Fable Python |> F# ♥️ Python"
15+ Description= " Demo Website, Fable Python running on Flask!"
16+ Banner= " https://unsplash.it/1200/900?random"
17+ PermaLink= " https://fable.io"
18+ Author= " dag@brattli.net"
19+ Brand= " public/favicon.png"
20+ }
21+
22+ let title ( str : string ) = Html.p [ prop.classes [ Bulma.Title ]; prop.text str ]
23+ let subTitle ( str : string ) = Html.p [ prop.classes [ Bulma.Subtitle ]; prop.text str ]
24+
25+ let helloWorld () =
26+ let body = Html.div [
27+ title site.Title
28+ subTitle site.Description
29+ ]
30+
31+ Html.html [
32+ Head.head site
33+
34+ Navbar.navbar site
35+ Hero.hero site body
36+ ]
37+ |> htmlPage
38+
39+ // Setup the routes. TODO: See if we can use attributes instead
40+ app.route( " /" )( helloWorld) |> ignore
1641
1742[<EntryPoint>]
18- let main args =
19- 1
43+ let main args = 1
Original file line number Diff line number Diff line change 88 <OutputType >Exe</OutputType >
99 </PropertyGroup >
1010 <ItemGroup >
11+ <Compile Include =" Model.fs" />
12+ <Compile Include =" Head.fs" />
13+ <Compile Include =" NavBar.fs" />
14+ <Compile Include =" Hero.fs" />
1115 <Compile Include =" App.fs" />
1216 </ItemGroup >
1317 <ItemGroup >
14- <ProjectReference Include =" ../../../Fable/src/Fable.Core/Fable.Core.fsproj" />
1518 <ProjectReference Include =" ../../src/Fable.Python.fsproj" />
1619 </ItemGroup >
17-
18- <Import Project =" ..\..\.paket\Paket.Restore.targets" />
20+ <Import Project =" .paket\Paket.Restore.targets" />
1921</Project >
Original file line number Diff line number Diff line change 1+ namespace Flask
2+
3+ open Feliz.ViewEngine
4+
5+ module Head =
6+ let head ( site : Site ) =
7+ Html.head [
8+ Html.title [ prop.text site.Title ]
9+
10+ Html.meta [ prop.charset.utf8 ]
11+ Html.meta [ prop.name " author" ; prop.content site.Author ]
12+ Html.meta [ prop.name " description" ; prop.content site.Description ]
13+
14+ Html.meta [ prop.httpEquiv.contentType; prop.content " text/html" ; prop.charset.utf8 ]
15+ Html.meta [ prop.name " viewport" ; prop.content " width=device-width, initial-scale=1" ]
16+
17+ Html.meta [
18+ prop.custom ( " http-equiv" , " Cache-Control" )
19+ prop.content " no-cache, no-store, must-revalidate"
20+ ]
21+ Html.meta [ prop.custom ( " http-equiv" , " Pragma" ); prop.content " no-cache" ]
22+ Html.meta [ prop.custom ( " http-equiv" , " Expires" ); prop.content " 0" ]
23+
24+ Html.link [ prop.rel " icon" ; prop.href " public/favicon.ico" ]
25+ Html.link [ prop.rel " stylesheet" ; prop.href " https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css" ; prop.crossOrigin.anonymous ]
26+ ]
Original file line number Diff line number Diff line change 1+ namespace Flask
2+
3+ open Feliz.ViewEngine
4+
5+ module Hero =
6+ let title ( str : string ) = Html.p [ prop.classes [ Bulma.Title ]; prop.text str ]
7+ let subTitle ( str : string ) = Html.p [ prop.classes [ Bulma.Subtitle ]; prop.text str ]
8+
9+ let hero ( site : Site ) body =
10+ Html.section [
11+ prop.classes [ Bulma.Hero; Bulma.IsFullheightWithNavbar ]
12+ prop.style [
13+ style.backgroundImageUrl ( site.Banner)
14+ style.backgroundPosition " center"
15+ style.backgroundSize.cover
16+ ]
17+ prop.children [
18+ Html.div [
19+ prop.classes [ Bulma.HeroBody; Bulma.IsDark ]
20+ prop.children [ Html.div [ prop.classes [ Bulma.Container ]; prop.children body ] ]
21+ ]
22+ ]
23+ ]
Original file line number Diff line number Diff line change 1+ namespace Flask
2+
3+ open Zanaptak.TypedCssClasses
4+
5+ type Bulma = CssClasses< " https://cdnjs.cloudflare.com/ajax/libs/bulma/0.9.3/css/bulma.min.css" , Naming.PascalCase>
6+
7+ type Site = {
8+ Author: string
9+ Banner: string
10+ Title: string
11+ Description: string
12+ PermaLink: string
13+ Brand: string
14+ }
Original file line number Diff line number Diff line change 1+ namespace Flask
2+
3+ open System
4+
5+ open Feliz.ViewEngine
6+
7+ module Navbar =
8+ let navbar ( site : Site ) =
9+ Html.nav [
10+ prop.classes [ Bulma.Navbar; Bulma.IsPrimary ]
11+ prop.children [
12+ Html.div [
13+ prop.classes [ Bulma.NavbarBrand ]
14+ prop.children [
15+ Html.a [
16+ prop.classes [ Bulma.NavbarItem ]
17+ prop.href site.PermaLink
18+ prop.children [
19+ Html.img [ prop.alt " Brand" ; prop.src ( site.Brand) ]
20+ Html.p [
21+ prop.classes [ Bulma.Title; Bulma.Is4 ]
22+ prop.text site.Title
23+ ]
24+ ]
25+ ]
26+ ]
27+ ]
28+
29+ Html.div [
30+ prop.classes [ Bulma.NavbarEnd ]
31+ prop.children [
32+ Html.div [
33+ prop.className Bulma.NavbarItem
34+ prop.children [
35+ Html.p [ prop.classes [ Bulma.Title; Bulma.Is6 ]; prop.text " Welcome to F# eXchange 2021" ]
36+ ]
37+ ]
38+ Html.div [
39+ prop.className Bulma.NavbarItem
40+ prop.children [
41+ Html.form [
42+ prop.action " /login"
43+ prop.method " get"
44+ prop.children [
45+ Html.input [
46+ prop.className Bulma.Button
47+ prop.type' " submit"
48+ prop.value " Login"
49+ ]
50+ ]
51+ ]
52+ ]
53+ ]
54+ ]
55+ ]
56+ ]
57+ ]
Original file line number Diff line number Diff line change 11#! /bin/bash
2- dotnet run -c Release -p ../../../Fable/src/Fable.Cli -- --lang Python --exclude Fable.Core
2+ dotnet fable-py -c Release
Original file line number Diff line number Diff line change 1+ source https://api.nuget.org/v3/index.json
2+ framework: net5.0
3+ storage: none
4+
5+ nuget Fable.Core.Experimental >= 4.0.0-alpha-003
6+ nuget Fable.Python
7+ nuget Feliz.ViewEngine
8+ nuget Zanaptak.TypedCssClasses
Original file line number Diff line number Diff line change 1+ STORAGE: NONE
2+ RESTRICTION: == net5.0
3+ NUGET
4+ remote: https://api.nuget.org/v3/index.json
5+ Fable.Core.Experimental (4.0.0-alpha-003)
6+ FSharp.Core (>= 4.7.2)
7+ Fable.Python (0.9)
8+ Fable.Core.Experimental (>= 4.0.0-alpha-002)
9+ FSharp.Core (>= 6.0)
10+ Feliz.ViewEngine (0.24)
11+ FSharp.Core (>= 4.7)
12+ FSharp.Core (6.0)
13+ Zanaptak.TypedCssClasses (1.0)
14+ FSharp.Core (>= 4.3.4)
You can’t perform that action at this time.
0 commit comments