2 ms·
Show HN: Func-to-web – Turn Python functions into web UIs with zero boilerplate
I needed a tool to quickly prototype internal utilities for our company – PDF generators, data processors, file converters that non-technical colleagues could use.
func-to-web generates web UIs from Python function signatures with zero boilerplate:
```python
from func_to_web import run
def divide(a: int, b: int):
return a / b
run(divide) # Web UI at localhost:8000
```
For more complex needs, it supports advanced types:
```python
def process_data(
scores: Annotated[
list[Annotated[int, Field(ge=0, le=100)]],
Field(min_length=3, max_length=10)
], # 3-10 items, each 0-100
files: list[ImageFile], # Multiple file uploads
email: Email, # Built-in validation
notes: str | None = None # Optional with toggle
):
return FileResponse(pdf_data, "report.pdf") # Auto-download
run(process_data)
```
Key features:
- *Advanced lists*: Dynamic add/remove with constraints on both list size and items
- *Optional fields*: `Type | None` creates toggle switches
- *File handling*: Upload/download with progress bars, supports GB+ files
- *Rich outputs*: Auto-displays PIL images, matplotlib plots, or downloadable files
- *Dynamic dropdowns*: Runtime-generated options from functions
- *Multiple functions*: Auto-generates index page
Not trying to replace full web frameworks, but for internal tools and quick utilities, this approach feels superior to writing HTML forms.
454 unit tests. Used daily for internal tools and rapid prototyping. Got 150 stars in the first week.
GitHub: https://github.com/offerrall/FuncToWeb https://github.com/offerrall/FuncToWeb
Sharing here in case others find it interesting too :)
- zahlman 1y agoFantastic concept. I've thought about making something like this before, but it seemed like a ton of design work / decision-making that I wasn't really up to. I'd suggest organizing the existing README into proper multi-page doc (e.g. on readthedocs.io) and having something much shorter in the actual README. What's currently there seems to make very little sense to read top-to-bottom.
- offerrall 1y agoThanks so much for the comment! I'll keep it in mind :)
- offerrall 1y agoUpdate: Took your advice and completely rewrote the docs! Now it's a proper multi-page documentation at https://offerrall.github.io/FuncToWeb/ https://offerrall.github.io/FuncToWeb/ with organized sections, examples, and screenshots for each feature. README is now short and focused. Thanks for the feedback :)