diff --git a/examples/django-minimal/.gitignore b/examples/django-minimal/.gitignore new file mode 100644 index 0000000..8e5bbf0 --- /dev/null +++ b/examples/django-minimal/.gitignore @@ -0,0 +1 @@ +*.py \ No newline at end of file diff --git a/examples/django-minimal/DjangoMinimal.fsproj b/examples/django-minimal/DjangoMinimal.fsproj new file mode 100644 index 0000000..c3f22c9 --- /dev/null +++ b/examples/django-minimal/DjangoMinimal.fsproj @@ -0,0 +1,15 @@ + + + + Exe + net5.0 + 3390;$(WarnOn) + + + + + + + + + \ No newline at end of file diff --git a/examples/django-minimal/Program.fs b/examples/django-minimal/Program.fs new file mode 100644 index 0000000..beee64b --- /dev/null +++ b/examples/django-minimal/Program.fs @@ -0,0 +1,51 @@ +// Learn more about F# at http://docs.microsoft.com/dotnet/fsharp +module Program + +open System +open System.Collections.Generic +open Fable.Core +open Fable.Python +open Fable.Core.PyInterop + +type ISettings = + [] + abstract configure : DEBUG: bool * ROOT_URLCONF : obj -> unit + + +[] +let settings: ISettings = nativeOnly +type IPath = + abstract path : url: string * view: obj -> obj + +[] +let urls: IPath = nativeOnly + + +[] +let HttpResponse: string -> obj = nativeOnly + + +[] +let execute_from_command_line: string [] -> int = nativeOnly + +[] +let sys : obj = nativeOnly + +[] +let sysModules : unit -> obj = nativeOnly + +settings.configure ( + DEBUG=true, + ROOT_URLCONF = sysModules +) + +let index request = + HttpResponse("

A minimal Django response!

") + +let urlpatterns = [| + urls.path ("",index) +|] + +[] +let main argv = + execute_from_command_line (sys?argv) diff --git a/examples/django-minimal/README.md b/examples/django-minimal/README.md new file mode 100644 index 0000000..8f65d59 --- /dev/null +++ b/examples/django-minimal/README.md @@ -0,0 +1,31 @@ +# Fable Python on Django + +A minimal example (single file). + +## Credits + +https://github.com/rnevius/minimal-django + +## Install Dependencies + +```sh +> dotnet tool restore +> dotnet restore + +> pip3 install -r requirements.txt +``` + +## Build + +``` +> dotnet fable-py +``` + +## Run + +```sh +> python3 program.py runserver +``` + +Visit http://127.0.0.1:8000/ + diff --git a/examples/django-minimal/requirements.txt b/examples/django-minimal/requirements.txt new file mode 100644 index 0000000..699ce5c --- /dev/null +++ b/examples/django-minimal/requirements.txt @@ -0,0 +1 @@ +Django>=3.2.8,<4.0.0 \ No newline at end of file