FastHTML #39
metaperl
started this conversation in
Framework Discussion: Specific
Replies: 1 comment
-
https://www.reddit.com/r/Python/comments/1eghskf/jeremy_howard_cofounder_of_fastai_released/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
FastHTML
Welcome to the official FastHTML documentation.
FastHTML is a new next-generation web framework for fast, scalable web
applications with minimal, compact code. It’s designed to be:
web apps you can imagine.
easy to build complex apps quickly.
FastHTML apps are just Python code, so you can use FastHTML with the
full power of the Python language and ecosystem. FastHTML’s
functionality maps 1:1 directly to HTML and HTTP, but allows them to be
encapsulated using good software engineering practices—so you’ll need to
understand these foundations to use this library fully. To understand
how and why this works, please read this first:
about.fastht.ml.
Installation
Since
fasthtml
is a Python library, you can install it with:In the near future, we hope to add component libraries that can likewise
be installed via
pip
.Usage
For a minimal app, create a file “main.py” as follows:
main.py
Running the app with
python main.py
prints out a link to your runningapp:
http://localhost:5001
. Visit that link in your browser and youshould see a page with the text “Hello World!”. Congratulations, you’ve
just created your first FastHTML app!
Adding interactivity is surprisingly easy, thanks to HTMX. Modify the
file to add this function:
main.py
You now have a page with a clickable element that changes the text when
clicked. When clicking on this link, the server will respond with an
“HTML partial”—that is, just a snippet of HTML which will be inserted
into the existing page. In this case, the returned element will replace
the original P element (since that’s the default behavior of HTMX) with
the new version returned by the second route.
This “hypermedia-based” approach to web development is a powerful way to
build web applications.
Next Steps
Start with the official sources to learn more about FastHTML:
FastHTML
write FastHTML code
app:
Heavily commented source code walking through a complete application,
including custom authentication, JS library connections, and database
use.
We also have a 1-hour intro video:
https://www.youtube.com/embed/Auqrm7WFc0I
The capabilities of FastHTML are vast and growing, and not all the
features and patterns have been documented yet. Be prepared to invest
time into studying and modifying source code, such as the main FastHTML
repo’s notebooks and the official FastHTML examples repo:
GitHub
Then explore the small but growing third-party ecosystem of FastHTML
tutorials, notebooks, libraries, and components:
Rendering
by Isaac Flath
Finally, join the FastHTML community to ask questions, share your work,
and learn from others:
Beta Was this translation helpful? Give feedback.
All reactions