Skip to content

Commit 116f563

Browse files
committed
add template
Signed-off-by: karthik Ganeshram <[email protected]>
1 parent 39cb3ec commit 116f563

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

templates/http-py/content/Pipfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
8+
[dev-packages]
9+
10+
[requires]
11+
python_version = "3.10"

templates/http-py/content/app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from spin_http import Response
2+
3+
def handle_request(request):
4+
5+
return Response(200,
6+
[("content-type", "text/plain")],
7+
bytes(f"Hello from the Python SDK", "utf-8"))
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
spin_version = "1"
2+
authors = ["{{authors}}"]
3+
description = "{{project-description}}"
4+
name = "{{project-name}}"
5+
trigger = { type = "http", base = "{{http-base}}" }
6+
version = "0.1.0"
7+
8+
[[component]]
9+
id = "{{project-name | kebab_case}}"
10+
source = "app.wasm"
11+
[component.trigger]
12+
route = "{{http-path}}"
13+
[component.build]
14+
command = "spin py2wasm app -o app.wasm"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[component]]
2+
id = "{{project-name | kebab_case}}"
3+
source = "{{ output-path }}/app.wasm"
4+
[component.trigger]
5+
route = "{{http-path}}"
6+
[component.build]
7+
command = "spin py2wasm app -o app.wasm"
8+
workdir = "{{ output-path }}"
9+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
manifest_version = "1"
2+
id = "http-py"
3+
description = "HTTP request handler using Python"
4+
5+
[add_component]
6+
skip_files = ["spin.toml"]
7+
skip_parameters = ["http-base"]
8+
[add_component.snippets]
9+
component = "component.txt"
10+
11+
[parameters]
12+
project-description = { type = "string", prompt = "Description", default = "" }
13+
http-base = { type = "string", prompt = "HTTP base", default = "/", pattern = "^/\\S*$" }
14+
http-path = { type = "string", prompt = "HTTP path", default = "/...", pattern = "^/\\S*$" }

0 commit comments

Comments
 (0)