Your Python code in index.py, running on Cloudflare Workers.
In addition to Wrangler and npm, you will need to install Transcrypt, including Python 3.7 and virtualenv.
To generate using wrangler
wrangler generate projectname https://github.com/cloudflare/python-worker-hello-world
Further documentation for Wrangler can be found here.
Before building your project, you'll need to do one-time setup of Transcrypt. Assuming you have Python and virtualenv installed per the linked instructions above,
cd projectname
virtualenv env
source env/bin/activate
pip install transcrypt
After that you can run Wrangler commands, such as wrangler publish
to push your code to Cloudflare. If you exit virtualenv (deactivate
) and return to the project directory later, you'll need to activate virtualenv (source env/bin/activate
) but will not need to rerun the other installation commands.
For more information on how Python translates to Javascript, see the Transcrypt docs.