diff --git a/01-hello/src/entry.py b/01-hello/src/entry.py
index 4b6a46f..abf34ca 100644
--- a/01-hello/src/entry.py
+++ b/01-hello/src/entry.py
@@ -1,4 +1,4 @@
-from js import Response
+from workers import Response
async def on_fetch(request, env):
- return Response.new("Hello world!")
+ return Response("Hello world!")
diff --git a/02-binding/src/entry.py b/02-binding/src/entry.py
index 19c0cbc..bf8f081 100644
--- a/02-binding/src/entry.py
+++ b/02-binding/src/entry.py
@@ -1,6 +1,6 @@
-from js import Response
+from workers 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"
+ return Response(bar) # returns "baz"
diff --git a/04-langchain/src/worker.py b/04-langchain/src/worker.py
index b21ca17..710b281 100644
--- a/04-langchain/src/worker.py
+++ b/04-langchain/src/worker.py
@@ -1,4 +1,4 @@
-from js import Response
+from workers import Response
from langchain_core.prompts import PromptTemplate
from langchain_openai import OpenAI
@@ -8,4 +8,4 @@ async def on_fetch(request, env):
chain = prompt | llm
res = await chain.ainvoke({"profession": "electrician"})
- return Response.new(res.split(".")[0].strip())
\ No newline at end of file
+ return Response(res.split(".")[0].strip())
diff --git a/05-query-d1/README.md b/05-query-d1/README.md
index 8a7329d..5ae7422 100644
--- a/05-query-d1/README.md
+++ b/05-query-d1/README.md
@@ -5,18 +5,26 @@ Warning: Python support in Workers is experimental and things will break. This d
Currently, Python Workers using packages cannot be deployed and will only work in local development for the time being.
### How to Run
+
Download this quotes file from [Hugging Face in SQL form](https://huggingface.co/datasets/lizziepika/quotes_sql/blob/main/data.sql)
Create a new D1 database by running on the command line `npx wrangler d1 create {D1-NAME}`. Copy and paste the output into your `wrangler.toml` to bind your D1 database to your Python Worker.
+Ingest the SQL file you've downloaded by running:
+
+```
+npx wrangler d1 execute {D1-NAME} --local --file=./data.sql
+```
+
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 demo.
+```
+
+Now, if you run `wrangler dev` within this directory, it should use the config in `wrangler.toml` to run the demo.
-You can also run `wrangler deploy` to deploy the demo.
+You can also run `wrangler deploy` to deploy the demo (though you'll need to repeat the ingestion step above for the remote DB).
-Finally, get a random quote from the database by visiting your deployed worker in the browser!
\ No newline at end of file
+Finally, get a random quote from the database by visiting your deployed worker in the browser!
diff --git a/05-query-d1/src/entry.py b/05-query-d1/src/entry.py
index 893f5f0..19120de 100644
--- a/05-query-d1/src/entry.py
+++ b/05-query-d1/src/entry.py
@@ -1,4 +1,4 @@
-from js import Response
+from workers import Response
async def on_fetch(request, env):
query = """
@@ -11,4 +11,4 @@ async def on_fetch(request, env):
data = results.results[0]
# Return a JSON response
- return Response.json(data)
\ No newline at end of file
+ return Response.json(data)
diff --git a/05-query-d1/wrangler.toml b/05-query-d1/wrangler.toml
index b7f6549..73653e7 100644
--- a/05-query-d1/wrangler.toml
+++ b/05-query-d1/wrangler.toml
@@ -1,5 +1,8 @@
#:schema node_modules/wrangler/config-schema.json
compatibility_date = "2024-08-06"
+main = "src/entry.py"
+compatibility_flags = ["python_workers"]
+
[ai]
binding = "AI"
@@ -7,4 +10,4 @@ binding = "AI"
[[d1_databases]]
binding = "DB" # i.e. available in your Worker on env.DB
database_name = "quotes" # REPLACE WITH YOUR DB NAME
-database_id = "408cddb7-e3f7-40d7-a4f7-33136a7fd3fa" # REPLACE WITH YOUR DB ID
\ No newline at end of file
+database_id = "408cddb7-e3f7-40d7-a4f7-33136a7fd3fa" # REPLACE WITH YOUR DB ID