A template for building your webapp with Python
Description •
Install •
Usage •
Use this template •
Docker •
Contribute
Documentation
oblique is a template repository for building your web application with FastAPI and HTMX.
Here is the list of tools used in this template :
FastAPIfor the web APIHTMXto have interactivity without JSJinjaXfor clean server-side componentsTailwindCSSfor component's designSQLite,sqlalchemy, andalembicfor the databaseDockerof course
Install oblique with :
git clone https://github.com/astariul/oblique.git
cd oblique
pip install -e .
You also need to build Tailwind CSS file :
pip install pytailwindcss
tailwindcss -o oblique/static/tailwind.css --minifyThis template is a simplistic web-application that retrieve some statistics from the PyPi API and display it to the user.
Just for demonstration purpose, you can check if the package is correctly installed by running :
obliqueYou can then navigate to http://0.0.0.0:9810/ and try the application.
To use this template, click the button "Use this template" :
It will prompt you to create a new Github repository.
Then replace the content in your freshly created repository, with your own code.
Check the exhaustive list of things to change in the documentation.
oblique provides a Dockerfile, so it's super easy to run.
First, clone the repository :
git clone https://github.com/astariul/oblique.git
cd clothionThen create the database with alembic :
mkdir ~/data
pip install alembic
OBLIQUE_DB_PATH="~/data/oblique.sql" alembic upgrade headAnd finally build the Docker image and run it :
docker build -t oblique .
docker run -p 9810:9810 -v ~/data:/oblique/data -e OBLIQUE_DB_PATH="/oblique/data/oblique.sql" obliqueTo contribute, install the package locally, create your own branch, add your code (and tests, and documentation), and open a PR !
Pre-commit hooks are set to check the code added whenever you commit something.
If you never ran the hooks before, install it with :
pre-commit installThen you can just try to commit your code. If your code does not meet the quality required by linters, it will not be committed. You can just fix your code and try to commit again !
You can manually run the pre-commit hooks with :
pre-commit run --all-filesWhen you contribute, you need to make sure all the unit-tests pass. You should also add tests if necessary !
You can run the tests with :
pytestTests are not included in the pre-commit hooks, because running the tests might be slow, and for the sake of developpers we want the pre-commit hooks to be fast !
Pre-commit hooks will not run the tests, but it will automatically update the coverage badge !
If you want to get the coverage report in HTML format, run :
pytest --cov-report=htmlAnd then open the file htmlcov/index.html with your browser.
The documentation should be kept up-to-date. You can visualize the documentation locally by running :
mkdocs serve