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

ParameterDefaultDescription
host"0.0.0.0"Server host
port8000Server port
authNone{username: password} dict
secret_keyautoSession signing key
app_titleautoPage title
css_varsNoneCSS variable overrides
faviconNonePath to favicon file
uploads_dir"./uploads"Uploaded files directory
max_file_sizeNoneMax upload size in bytes
keep_uploadsFalseKeep uploads after execution
returns_dir"./returned_files"Returned files directory
returns_lifetime3600Seconds before returned files are deleted
stream_printsTrueStream print() to browser
root_path""URL prefix for reverse proxy
fastapi_configNoneExtra FastAPI options
front_dirNoneDirectory mounted at /front (with html=True for SPA-style routing)
assets_dirNoneDirectory mounted at /assets for static files
**uvicorn_kwargsAny 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"],
)