Project structure
Info
This guide assumes you have created your app using Hyperflask-Start
In your project folder, you will find the following files and folders:
- app: your app code
- assets: scripts and stylesheets that will be bundled using esbuild
- main.css: tailwind entrypoint
- components: components to compose your app
- pages: your site pages
- assets: scripts and stylesheets that will be bundled using esbuild
- public: all files in this folder are publicly accessible
- tests: tests using pytest
- .env: environment variables
- config.yml: your app configuration file
- Dockerfile: Dockerfile to build your production image
- pyproject.toml: list python dependencies and tool options
- package.json: list javascript dependencies
When using the hyperflask
command, an Hyperflask app instance will be automatically created from the app folder.
Info
If you are coming from Flask, this means you do not create the app
object yourself.
The actuall application object is available at hyperflask.factory:app
(or hyperflask:current_app
when in app context).
The app folder is available as a python package and the following will be automatically imported from it if they exist:
- models : to define your database models
- routes : to define app routed endpoints
- tasks: to define background tasks using dramatiq
- cron: to define scheduled tasks using dramatiq
- cli: to define command line tasks
Define them as modules (eg. app/models.py
) or packages (eg. app/models/__init__.py
)?
To import things from the rest of your app:
# app/models.py
from hyperflask.factory import db
class MyModel(db.Model):
pass
# anywhere else
from app.models import MyModel