搜索

PythonReactSEOPDF
GitHub Skill

cloudflare

For CloudFlare development, deployment, e.g. Python CloudFlare Workers

sanand0☆ 7 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

General

  • Modifying code while wrangler dev is running slows it down. Stop, edit, then restart.

Python Cloudflare Workers

Sample wrangler.toml:

name = "..."
main = "..."
compatibility_date = "..."
compatibility_flags = ["python_workers"]

[observability]
enabled = true

Sample entry.py:

from workers import Response, WorkerEntrypoint

class Default(WorkerEntrypoint):
    async def fetch(self, request, env) -> Response:
        return Response('{"x": 1}', headers={"content-type": "application/json"})

To integrate a FastAPI app:

from workers import WorkerEntrypoint
from my_fastapi_app import app
import asgi

class Default(WorkerEntrypoint):
   async def fetch(self, request):
       return await asgi.fetch(app, request.js_object, self.env)

Usage notes:

  • Ensure there's a pyproject.toml with dependencies.
  • Prep env: uv add --dev workers-py workers-runtime-sdk
  • Vendor deps (if any): uv run pywrangler sync (uses python_modules).
  • Dev: uv run pywrangler dev then hit http://localhost:8787.
  • Deploy: uv run pywrangler deploy.
  • Verify: curl https://<worker-name>.<account>.workers.dev.

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-30
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!