Lets learn FastHTML. It's been branded as a quick and nice way to get a site running.
Kalle Tolonen
Sept. 9, 2024
I like to keep my Python stuff in dedicated virtual environments.
virtualenv env -p python3 --system-site-packages
Let's use the installed env:
/minimal$ source env/bin/activate
(env) kallet@mm:~/minimal$ which pip
/home/kallet/minimal/env/bin/pip
Since we're in the desired env, let's install the framework:
$ pip install python-fasthtml
And make a main.py:
from fasthtml.common import *
app,rt = fast_app()
# This is a route where we'll navigate with the '/''url
@rt('/')
def get(): return Div(P('Hello Doge'), hx_get="/change")
serve()
Then run it with:
python main.py
These should be the results:
$ python main.py
Link: http://localhost:8010
INFO: Will watch for changes in these directories: ['/home/kallet/minimal']
INFO: Uvicorn running on http://0.0.0.0:8010 (Press CTRL+C to quit)
INFO: Started reloader process [381100] using WatchFiles
INFO: Started server process [381106]
INFO: Waiting for application startup.
INFO: Application startup complete
So now we have a web server running locally!
That was actually quite fast.
No published comments yet.
Your comment may be published.