Dullaz
Dullaz
CDCloudflare Developers
Created by eCat on 6/14/2024 in #workers-help
Help For A Email Response API
Hey, got any code to share? What’s your flow?
3 replies
CDCloudflare Developers
Created by saito200 on 6/8/2024 in #workers-help
Return ok status immediately on async process or not?
ahh yes, sorry for that 😄
4 replies
CDCloudflare Developers
Created by saito200 on 6/8/2024 in #workers-help
Return ok status immediately on async process or not?
app.post (from telegram) retrieve user message send 200 response send message to OpenAI API wait for OpenAI response Send OpenAI response to Telegram API return
This should work, you can run the logic for communicating with openAI and telegram api in an async function. make sure you call it with
ctx.waitUntil
ctx.waitUntil
For example
export default {
async fetch(request, env, ctx) {
ctx.waitUntil(aiLogic())
return new Response("ok!");
},
};

async function aiLogic() {
functionToCallOpenAi();
functionToMessageTelegram();
}
export default {
async fetch(request, env, ctx) {
ctx.waitUntil(aiLogic())
return new Response("ok!");
},
};

async function aiLogic() {
functionToCallOpenAi();
functionToMessageTelegram();
}
The ctx.waitUntil makes sure the worker stays alive after the response has been returned until the aiLogic promise is resolved
4 replies
CDCloudflare Developers
Created by mune on 5/26/2024 in #workers-help
Worker Routes not working
Fetch -> handleRequest. handleRequest -> fetch? Am I missing something or is this a weird loop?
10 replies
CDCloudflare Developers
Created by mune on 5/26/2024 in #workers-help
Worker Routes not working
I built a url shortener on cf workers using nextjs, and it works so this is definitely possible. that being said, i dont understand why handleRequest returns fetch(request) if location is not found. might be better to keep it all in one function and refactor after it starts working.
10 replies
CDCloudflare Developers
Created by mune on 5/26/2024 in #workers-help
Worker Routes not working
Huh? It loops back into the first method?
10 replies
CDCloudflare Developers
Created by mune on 5/26/2024 in #workers-help
Worker Routes not working
What does ‘fetch(request)’ do?
10 replies
CDCloudflare Developers
Created by Adi on 5/26/2024 in #workers-help
fetch() not working
Nice! Thought it might be that
18 replies
CDCloudflare Developers
Created by Adi on 5/26/2024 in #workers-help
fetch() not working
The worker might be terminating before it finishes
18 replies
CDCloudflare Developers
Created by Adi on 5/26/2024 in #workers-help
fetch() not working
Ahh but on cf workers you might need to use waitUntil on async functions
18 replies
CDCloudflare Developers
Created by Adi on 5/26/2024 in #workers-help
fetch() not working
‘await’ the fetch no?
18 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
14 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
for now i guess developing it locally is the only option
14 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
I think they just aren't ready yet - it does seem to imply that fastapi is a built-in package but maybe it isnt yet
14 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
yup, I'm running into the same issue when deploying the CloudFlare examples from https://developers.cloudflare.com/workers/languages/python/packages/fastapi#get-started
14 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
Interessant - I'm giving it a spin locally now
14 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
can you try
from fastapi import FastAPI, Request
from fastapi import FastAPI, Request
instead?
14 replies
CDCloudflare Developers
Created by Ankita Tudubucket on 5/11/2024 in #workers-help
Conflict between Cloudflare Workers checks & Cloudflare docs
Python Workers are in open beta.
You can currently only use built-in packages in local development. Support for deploying packages with a requirements.txt file is coming soon.
Python Workers are in open beta.
You can currently only use built-in packages in local development. Support for deploying packages with a requirements.txt file is coming soon.
What do your imports look like? You shouldn't need a requirements.txt file to import the built-in packages
14 replies
CDCloudflare Developers
Created by moonchav on 5/10/2024 in #workers-help
Are there analytics for which endpoints on my worker are being requested, and request methods?
3 replies