Deploy Python web apps, workers and scheduled scripts
Serve a WSGI endpoint, run a background worker, or save the result of a scheduled Python command with a bounded timeout.
Start a Python web app
Open Lưu trữ Python and choose Ứng dụng web Python. Download the Python HTTP example and upload its project to Files. Set MAIN_FILE tới main.py, start the deployment, and copy the HTTPS address from Settings.
Open the address in a browser. The example’s home page links to /api/health. Open that link and check the response below. This exercises the WSGI application and its public route together.
{"service": "python-web", "status": "ok"}Start a framework project
Keep requirements.txt at the project root and include your chosen server dependency. The sample uses a small standard-library server for its demonstration. For an ASGI application named app in main.py with Uvicorn in its requirements, set RUN_COMMAND to the following command. Adjust the module and object names to match your project.
python -m pip install -r requirements.txt && python -m uvicorn main:app --host 0.0.0.0 --port "$SERVER_PORT"Dùng Variables for credentials và Deploy for a connected branch. After a code change, check Console for import errors and request a route that exercises the changed code.
Observe a background process
Mẫu Worker luôn chạy profile suits a process that continuously consumes work. Upload the worker example, start main.py and watch Console for a timestamped heartbeat each minute. Use flush=True on progress messages when you need them to appear immediately.
Run a finite script once or on an interval
Choose Script Python chạy một lần for a manual task or Script Python theo lịch for recurring work. The job example writes a JSON report and exits. Upload it at the root. Start the runner and select Chạy ngay in Runs. Check the exit result and the finished timestamp.
On the scheduled profile, set JOB_INTERVAL_SECONDS tới 3600 for an hourly UTC interval. Set JOB_TIMEOUT_SECONDS to a suitable limit, save and restart. Runs shows the next occurrence and recent outcomes. A value of 0 for the interval pauses the schedule. See handling missed and overlapping runs before relying on a recurring report.