Python app
Run Python services from files or a GitHub repo.
- app
- language
Guides: Run your own app, Run a GitHub repo
Run it
briq run pythonbriq_run({ recipe: "python", wait: true })curl -X POST https://api.briq.cloud/v1/briqs \
-H "Authorization: Bearer $BRIQ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"recipe": "python",
"wait": true
}'
# → { "briqs": [{ "id": "bq_…", … }], "outputs": { "APP_URL": "…" }, … }
# ... when done, for each briq id
curl -X DELETE https://api.briq.cloud/v1/briqs/<id> \
-H "Authorization: Bearer $BRIQ_API_KEY"stack: app
services:
app:
recipe: python
# its defaults, each a field you can set:
# image: python:3.12-slim
# ports: [8080]
# size: smallFields
| Name | Type | Options | Default |
|---|---|---|---|
| image | string | — | "python:3.12-slim" |
| files | record | { "path": "content" | { base64 } } | — |
| checkout | object | { repo, ref?, path?, token? } | — |
| steps | object[] | — | — |
| cmd | string | string[] | — | — |
| ports | number[] | — | [8080] |
| env | record | { key: string | { secret, value?, literal?, scope?, hosts?, locations? } } | {} |
| size | enum | nano, small, medium, large | "small" |
| volume | object | { gb? } | — |
| egress | object | { hosts } | — |
Outputs
Returned by briq_run once the stack is healthy. Hosts resolve inside your team network; secrets are generated per run.
- APP_URL
- http://app.<stack>.internal:8080
What it runs
| Briq | Image | Ports | Size | Volume |
|---|---|---|---|---|
| app | python:3.12-slim | 8080 | small | — |
When to use it
- You wrote a small Flask, FastAPI or plain
http.serverapp and want it running next to its database, with a URL, without building an image. - A script should run as a service: a webhook receiver, a scheduler, a bot.
Tips
- Code in a repo: pass
checkout: { repo: "github.com/owner/app" }instead offiles. See Run a GitHub repo. - A bot or a scheduler that only makes outgoing calls is not seen as use, so it sleeps after
its
sleepwindow. Give itsleep: "never"(always on, Pro plan and above), or a window longer than the gap between its runs. - Pass the code as
files:{ "app.py": "…", "requirements.txt": "flask\npsycopg[binary]" }. Relative paths go under/app, the working directory. They are written before the app starts, and again whenever it starts over. requirements.txtis installed at each start;packages: ["flask"]adds more without a file. The packages stay on the briq's disk, so after the first start the install is quick.startis the command when it is notpython app.py, e.g."uvicorn main:app --host :: --port 8080".- Listen on
::and on$PORT(8080 by default): the private network is IPv6. - Wire a database with
env: run the postgres recipe in the same stack first and pass itsDATABASE_URLas a secret,{ secret: "DATABASE_URL", value: "…" }. - Publish it as you run it:
briq_run({ recipe: "python", files, expose: "private" })returnsURL("public"instead of"private"for anyone). - If it exits before it answers, the run fails and the briq is in
error;briq_logsshows the traceback.briq_destroyit, fix the files, and run again. If it exits later, the briq stops with the code inlastExit. - Step by step: Run your own app, with a database and a URL.