Skip to content

GamerC0der/hej

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hej

Hej is a simple framework, similar to Flask and FastHTML, in one simple package.

Supports

  • FastHTML Style Syntax
  • Templates
  • Debug Mode
  • CLI
  • 404 Pages

& More

Hej Framework Documentation

Quick Start

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.py

Visit http://127.0.0.1:5000 to see your app!

Adding Routes

Add more routes using decorators:

@get('/about')
def about():
    return html.html(
        html.head(
            html.title('About')
        ),
        html.body(
            html.h1('About Page')
        )
    )

Using Templates

You can return a template file name as a string:

@get('/page')
def page():
    return 'example.html'

404 Handling

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!')
        )
    )

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors