Skip to content

Commit f116623

Browse files
Add @handler to Python templates. (#9305)
Co-authored-by: Carmen Popoviciu <[email protected]>
1 parent 251bad3 commit f116623

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

.changeset/funny-onions-post.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-cloudflare": minor
3+
---
4+
5+
Add @handler to Python templates.

packages/create-cloudflare/templates/hello-world-durable-object-with-assets/py/src/entry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from workers import DurableObject, Response
1+
from workers import DurableObject, Response, handler
22

33
"""
44
* Welcome to Cloudflare Workers! This is your first Durable Objects application.
@@ -48,6 +48,7 @@ async def say_hello(self, name):
4848
* @param {ExecutionContext} ctx - The execution context of the Worker
4949
* @returns {Promise<Response>} The response to be sent back to the client
5050
"""
51+
@handler
5152
async def on_fetch(request, env, ctx):
5253
# Create a `DurableObjectId` for an instance of the `MyDurableObject`
5354
# class named "foo". Requests from all Workers to the instance named

packages/create-cloudflare/templates/hello-world-durable-object/py/src/entry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from workers import DurableObject, Response
1+
from workers import DurableObject, Response, handler
22

33
"""
44
* Welcome to Cloudflare Workers! This is your first Durable Objects application.
@@ -48,6 +48,7 @@ async def say_hello(self, name):
4848
* @param {ExecutionContext} ctx - The execution context of the Worker
4949
* @returns {Promise<Response>} The response to be sent back to the client
5050
"""
51+
@handler
5152
async def on_fetch(request, env, ctx):
5253
# Create a `DurableObjectId` for an instance of the `MyDurableObject`
5354
# class named "foo". Requests from all Workers to the instance named

packages/create-cloudflare/templates/hello-world-with-assets/py/src/entry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from workers import Response
1+
from workers import Response, handler
22
from uuid import uuid4
33
from urllib.parse import urlparse
44

5+
@handler
56
async def on_fetch(request, env):
67
url = urlparse(request.url)
78
if url.path == '/message':

0 commit comments

Comments
 (0)