File tree Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Expand file tree Collapse file tree 5 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 1+ * .py
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <Project Sdk =" Microsoft.NET.Sdk" >
3+ <PropertyGroup >
4+ <OutputType >Exe</OutputType >
5+ <TargetFramework >net5.0</TargetFramework >
6+ <WarnOn >3390;$(WarnOn)</WarnOn >
7+ </PropertyGroup >
8+ <ItemGroup >
9+ <Compile Include =" Program.fs" />
10+ </ItemGroup >
11+ <ItemGroup >
12+ <PackageReference Include =" Fable.Python" Version =" 0.12.0" />
13+ <PackageReference Include =" Fable.Core.Experimental" Version =" 4.0.0-alpha-005" />
14+ </ItemGroup >
15+ </Project >
Original file line number Diff line number Diff line change 1+ // Learn more about F# at http://docs.microsoft.com/dotnet/fsharp
2+ module Program
3+
4+ open System
5+ open System.Collections .Generic
6+ open Fable.Core
7+ open Fable.Python
8+ open Fable.Core .PyInterop
9+
10+ type ISettings =
11+ [<Emit( " $0.configure(DEBUG=$1, ROOT_URLCONF=$2)" ) >]
12+ abstract configure : DEBUG : bool * ROOT_URLCONF : obj -> unit
13+
14+
15+ [<ImportMember( " django.conf" ) >]
16+ let settings : ISettings = nativeOnly
17+ type IPath =
18+ abstract path : url : string * view : obj -> obj
19+
20+ [<ImportMember( " django" ) >]
21+ let urls : IPath = nativeOnly
22+
23+
24+ [<ImportMember( " django.http" ) >]
25+ let HttpResponse : string -> obj = nativeOnly
26+
27+
28+ [<ImportMember( " django.core.management" ) >]
29+ let execute_from_command_line : string [] -> int = nativeOnly
30+
31+ [<ImportAll( " sys" ) >]
32+ let sys : obj = nativeOnly
33+
34+ [<Emit( " sys.modules[__name__]" ) >]
35+ let sysModules : unit -> obj = nativeOnly
36+
37+ settings.configure (
38+ DEBUG= true ,
39+ ROOT_ URLCONF = sysModules
40+ )
41+
42+ let index request =
43+ HttpResponse( " <h1>A minimal Django response!</h1>" )
44+
45+ let urlpatterns = [|
46+ urls.path ( " " , index)
47+ |]
48+
49+ [<EntryPoint>]
50+ let main argv =
51+ execute_ from_ command_ line ( sys?argv)
Original file line number Diff line number Diff line change 1+ # Fable Python on Django
2+
3+ A minimal example (single file).
4+
5+ ## Credits
6+
7+ https://github.com/rnevius/minimal-django
8+
9+ ## Install Dependencies
10+
11+ ``` sh
12+ > dotnet tool restore
13+ > dotnet restore
14+
15+ > pip3 install -r requirements.txt
16+ ```
17+
18+ ## Build
19+
20+ ```
21+ > dotnet fable-py
22+ ```
23+
24+ ## Run
25+
26+ ``` sh
27+ > python3 program.py runserver
28+ ```
29+
30+ Visit http://127.0.0.1:8000/
31+
Original file line number Diff line number Diff line change 1+ Django >= 3.2.8 ,< 4.0.0
You can’t perform that action at this time.
0 commit comments