Transform any Python function into a web interface automatically
Project description
Func To Web
Type hints → Web UI. Turn Python functions into web apps — standalone or mounted inside yours.
One typed Python function → form + iframe + HTTP endpoint, simultaneously. It's a library, not a framework: it composes with what you already have.
- Standalone —
run(func). Internal tools, admin panels, scripts. The auto-generated UI is the app. - Mounted —
create_app(funcs)returns a plain FastAPI app. Mount it under any prefix of your existing app; every URL adapts automatically. - Embedded — drop forms into existing sites via
<iframe>with URL prefill. "Export to PDF" buttons, CSV importers, modal editors.
Validation, file uploads, SSE streaming, downloads, custom widgets and outputs via return types and Annotated metadata — all built-in. Auto-generated API docs at /doc for scripts and AI agents: write a function, get a UI and an API for free.
Quick start
pip install func-to-web
from func_to_web import run
def divide(a: float, b: float):
return a / b
run(divide)
Open http://127.0.0.1:8000. Done.
Mount it inside your FastAPI app
from fastapi import FastAPI
from func_to_web import create_app
def add(a: int, b: int):
return a + b
host = FastAPI()
host.mount("/tools", create_app(add))
uvicorn app:host
Open http://127.0.0.1:8000/tools/. Forms, validation, downloads — everything works under the prefix, zero configuration. Serving by import string also unlocks --workers and --reload.
A function is a feature of your site
Mounted, every function is also an embeddable form. Write the function:
def edit_user(id: int, name: str, email: Email):
db.update(id, name, email)
return "Updated"
Embed it, prefilled, from any page of your site:
<iframe src="/tools/edit-user?__embed=1&id=42&name=Alice"></iframe>
That iframe is the complete feature: the form is generated from the type hints, rendered fresh on each open (live Dropdown(func) choices included), validated server-side on /submit — the form is a view, the endpoint is what validates. No form code in your frontend, no schema duplication. An embedded form document is a few kB; the shared CSS/JS bundle is cacheable.
To call functions without UI, every endpoint is a plain POST /<slug>/submit returning an SSE stream — the full protocol is documented at /doc, readable by scripts and AI agents.
Inputs
| Type | Widget | Docs |
|---|---|---|
int, float |
Number / slider | → |
str, Email |
Text / textarea / password | → |
bool |
Toggle | → |
date, time |
Pickers | → |
Color |
Hex picker | → |
File, ImageFile, VideoFile, ... |
Upload | → |
Literal, Enum, Dropdown(func) |
Select | → |
list[T] |
Dynamic list | → |
T | None |
Toggle + input | → |
Params |
Reusable groups | → |
Annotated[T, ...] |
Type Composition, Constraints, labels, sliders | → |
Outputs
| Return type | Rendered as | Docs |
|---|---|---|
str, int, float, None |
Text + copy button | → |
PIL Image, Matplotlib Figure |
Inline image | → |
FileResponse |
Download button | → |
DataFrame, list[dict], ... |
Table | → |
tuple / list |
Multiple outputs | → |
print() |
Streamed live | → |
Features
create_app()— get a mountable FastAPI app, serve by import string (workers, reload) — docs- Multiple functions with an index page — docs
- URL prefill — open forms with values from query params — docs
- Embed mode — drop any form into your site via
?__embed=1— docs - Auto-generated API docs at
/docfor scripts and AI agents — docs - Server config — host, port, reverse proxy — docs
Full docs with examples and screenshots: docs/ — one page per feature, browsable right here on GitHub.
Examples
File transfer
from func_to_web import run, File
import shutil, os
downloads = os.path.expanduser("~/Downloads")
def upload_files(files: list[File]):
for f in files:
shutil.move(f, downloads)
return "Done."
run(upload_files)
QR code generator
import qrcode
from func_to_web import run
def make_qr(text: str):
return qrcode.make(text).get_image()
run(make_qr)
Admin panel
import subprocess
from typing import Literal
from func_to_web import run
def restart_service(service: Literal['nginx', 'gunicorn', 'celery']):
subprocess.run(["sudo", "supervisorctl", "restart", service], check=True)
return f"{service} restarted."
# Deploy sensitive tools behind a reverse proxy with auth (e.g. Nginx
# basic auth) — see docs/features/configuration.md.
run(restart_service)
More in examples/.
Install
pip install func-to-web # stable
pip install git+https://github.com/offerrall/FuncToWeb.git # latest
Requirements: Python 3.10+. Core deps installed automatically; Pillow, Matplotlib, Pandas, NumPy and Polars are optional.
Stability
FuncToWeb is in its fast-iteration phase, and that's deliberate. Until 2.0.0 the priority is getting the design right, not preserving it: features that turn out to have a better home in another layer get removed, APIs get reshaped, and minor releases can break things. Every breaking change is explicit — documented in the CHANGELOG with the reasoning and the migration path, never silent.
If you depend on it today, pin your version (e.g. func-to-web==1.6.0) and
read the changelog before upgrading.
The 2.0.0 commitment: from 2.0.0 onwards, FuncToWeb adopts semantic versioning for real — breaking changes only in major releases, with deprecation warnings beforehand. The churn now is what buys a stable, small API later.
Built on pytypeinput and pytypeinputweb, usable standalone for CLIs, Qt apps, etc.
Feedback, issues and contributions welcome — they keep the project moving.
MIT License · Made by Beltrán Offerrall
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file func_to_web-1.6.0.tar.gz.
File metadata
- Download URL: func_to_web-1.6.0.tar.gz
- Upload date:
- Size: 42.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e24219a83458b0321e2a9485df29bb6f9375363783a320cdb4b03bee8fe5e48d
|
|
| MD5 |
0e1c55a12ce6f8b31af08c4c6443dfd0
|
|
| BLAKE2b-256 |
bf2b1ca7b62fb3f5826a701222e7a80c329885ec3993496fe7442e9e071f2d87
|
File details
Details for the file func_to_web-1.6.0-py3-none-any.whl.
File metadata
- Download URL: func_to_web-1.6.0-py3-none-any.whl
- Upload date:
- Size: 49.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6da75bbb4617f166b0680df141eb338090d9e1269eaee25842b44425d61bf4b
|
|
| MD5 |
03265413c7871e60b1660a7ae2f6e7cf
|
|
| BLAKE2b-256 |
5a49d97c2b849bc0eca287d62eaa2b34d0e6d3781e02d2a8d874a57d36e435dc
|