Server Configuration
May 1, 2026 · View on GitHub
FuncToWeb runs a FastAPI/Uvicorn server. The recommended setup is binding to 127.0.0.1 and letting Nginx act as reverse proxy
Basic
from func_to_web import run
run(my_function, host="127.0.0.1", port=8000)
All Parameters
| Parameter | Default | Description |
|---|---|---|
host | "0.0.0.0" | Server host |
port | 8000 | Server port |
auth | None | {username: password} dict |
secret_key | auto | Session signing key |
app_title | auto | Page title |
css_vars | None | CSS variable overrides |
favicon | None | Path to favicon file |
uploads_dir | "./uploads" | Uploaded files directory |
max_file_size | None | Max upload size in bytes |
keep_uploads | False | Keep uploads after execution |
returns_dir | "./returned_files" | Returned files directory |
returns_lifetime | 3600 | Seconds before returned files are deleted |
stream_prints | True | Stream print() to browser |
root_path | "" | URL prefix for reverse proxy |
fastapi_config | None | Extra FastAPI options |
front_dir | None | Directory mounted at /front (with html=True for SPA-style routing) |
assets_dir | None | Directory mounted at /assets for static files |
**uvicorn_kwargs | — | Any Uvicorn option |
Any option supported by Uvicorn or FastAPI can be passed through — fastapi_config for FastAPI constructor kwargs, and **uvicorn_kwargs for everything else.
Common Setups
Localhost only:
run(my_function, host="127.0.0.1")
Custom port:
run(my_function, port=5000)
Reverse proxy with path prefix:
run(my_function, root_path="/tools/my-app")
Custom frontend + static assets:
run(
my_function,
front_dir="./my-site", # served at /front (SPA-style routing)
assets_dir="./assets", # served at /assets (images, fonts, downloads)
)
front_dir is mounted with html=True, so unknown paths fall back to index.html — drop a static site or a built React/Vue/Svelte bundle next to your Python functions and the same FuncToWeb process serves both.
Both directories are excluded from the auth middleware, so static content is reachable without login.
Nginx + Supervisor
The recommended setup: Supervisor keeps the process alive, Nginx handles SSL termination and proxies to FuncToWeb on localhost. Set root_path to match the Nginx location, and disable proxy buffering if you use stream_prints=True.
Production Example
import os
from func_to_web import run
run(
my_functions,
host="127.0.0.1",
port=8000,
auth={"admin": os.environ["ADMIN_PASSWORD"]},
secret_key=os.environ["SECRET_KEY"],
)