Blog

A Python app on the panel: code, environment values, logs, cron and a preview

Run a Python web app on a panel domain: send its code as a package, set environment values, read the logs, restart it, schedule a file with cron and make a preview copy. Includes the one-app-folder limit.

A Python app on the panel: code, environment values, logs, cron and a preview

2026-11-29

A Python app runs as the account's own system user. The panel starts it on a free port between 3000 and 3999, gives it the PORT value in its environment, and serves it through nginx on its domain. Our test app printed a greeting and served JSON through the Cloudflare proxy.

1. Attach a domain

  1. Attach the domain to an account on the Domains page, or add a subdomain under it on the Subdomains and redirects page.

2. Write the code

tar -czf app.tar.gz -C app .
  1. Write main.py. It listens on 127.0.0.1 and on the port in the PORT variable: HTTPServer(('127.0.0.1', int(os.environ.get('PORT', '3000'))), Handler).
  2. Pack the folder as a tar.gz with main.py at the top level, plus any other files such as cron.py.
  3. Send the package with the deploy call: packageBase64 holds the base64 text of the tar.gz, kind is python and entry is main.py. The deploy runs at once within the token's policy.

3. Environment values

  1. set_env_value stores a value sealed on the server. The value applies on the next restart.
  2. list_env_keys shows only the names. No tool shows a value again.
  3. restart_app restarts the app with its code and its values.

4. Check it

  1. app_status says active while the process runs.
  2. read_app_logs returns the last lines: the start line, the request lines and anything the app prints.
  3. curl -sS https://your-app-domain/ returns the app's text with status 200.

5. Cron

  1. add_cron_job takes the account id, a five-field schedule such as */5 * * * *, kind python and entry cron.py. The file must already be in the app folder.
  2. list_cron_jobs shows the job. To see its last run, check the file the job writes, or the incident list if it fails.

6. Preview

  1. create_preview makes a copy of the current code on its own host, such as id.preview.your-app-domain. It expires after 24 hours.
  2. Check it with curl --resolve, because the preview host needs its own public DNS record for a normal visit.

The limit: one app folder per account

All apps of one account share one app folder. A new package for one domain replaces that folder for every app of the account. The helper keeps the old folder as app.previous. If a deploy fails after that step, the folder may already have changed, so keep a copy of your code. Give each app its own account, or put the code of every app of the account into one package.

All posts