-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 061f3c5
Showing
7 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
**/.wrangler | ||
**/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Hello World Example | ||
|
||
Warning: Python support in Workers is experimental and things will break. This | ||
example is meant for reference only right now; you should be prepared to update | ||
your code between now and official release time as APIs may change. | ||
|
||
## How to Run | ||
First ensure that your Wrangler version is up to date (3.30.0 and above). | ||
``` | ||
$ wrangler -v | ||
⛅️ wrangler 3.30.0 | ||
``` | ||
|
||
Now, if you run `wrangler dev` within this directory, it should use the config | ||
in `wrangler.toml` to run the example. | ||
|
||
You can also run `wrangler deploy` to deploy the example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from js import Response | ||
|
||
async def on_fetch(request, env): | ||
return Response.new("Hello world!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name = "hello-python-worker" | ||
main = "src/entry.py" | ||
compatibility_flags = ["python_workers"] | ||
compatibility_date = "2024-03-29" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Bindings Example | ||
|
||
Warning: Python support in Workers is experimental and things will break. This | ||
example is meant for reference only right now; you should be prepared to update | ||
your code between now and official release time as APIs may change. | ||
|
||
## How to Run | ||
First ensure that your Wrangler version is up to date (3.30.0 and above). | ||
``` | ||
$ wrangler -v | ||
⛅️ wrangler 3.30.0 | ||
``` | ||
|
||
Now, you must set up a [KV namespace](https://developers.cloudflare.com/kv/reference/kv-namespaces/). Edit `wrangler.toml` to reflect the KV namespace you created. | ||
|
||
Now, if you run `wrangler dev` within this directory, it should use the config | ||
in `wrangler.toml` to run the example. | ||
|
||
You can also run `wrangler deploy` to deploy the example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from js import Response | ||
|
||
async def on_fetch(request, env): | ||
await env.FOO.put("bar", "baz") | ||
bar = await env.FOO.get("bar") | ||
return Response.new(bar) # returns "baz" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name = "hello-python-bindings" | ||
main = "src/entry.py" | ||
compatibility_flags = ["python_workers"] | ||
compatibility_date = "2024-03-29" | ||
|
||
kv_namespaces = [ | ||
{ binding = "FOO", id = "<YOUR_KV_NAMESPACE_ID>" } | ||
] |