Hej is a simple framework, similar to Flask and FastHTML, in one simple package.
- FastHTML Style Syntax
- Templates
- Debug Mode
- CLI
- 404 Pages
& MoreMore
Create a file called app.py and add this code:
import hej
from hej import html, get
@get('/')
def home():
return html.html(
html.head(
html.title('My App')
),
html.body(
html.h1('Hello, World!'),
html.p('Welcome to Hej Framework')
)
)
if __name__ == '__main__':
hej.run()Run it with:
python app.pyVisit http://127.0.0.1:5000 to see your app!
Add more routes using decorators:
@get('/about')
def about():
return html.html(
html.head(
html.title('About')
),
html.body(
html.h1('About Page')
)
) )You can return a template file name as a string:
@get('/page')
def page():
return 'example.html'Handle 404 errors with a custom page:
@hej.not_found
def custom_404():
return html.html(
html.head(
html.title('404 Not Found')
),
html.body(
html.h1('404 Not Found'),
html.p('This page doesn\'t exist!')
)
) )