Skip to content

Repository files navigation

oblique

A template for building your webapp with Python

GitHub release Test status Lint status Coverage status Docs licence

DescriptionInstallUsageUse this templateDockerContribute
Documentation

Description

oblique is a template repository for building your web application with FastAPI and HTMX.

Here is the list of tools used in this template :

  • FastAPI for the web API
  • HTMX to have interactivity without JS
  • JinjaX for clean server-side components
  • TailwindCSS for component's design
  • SQLite, sqlalchemy, and alembic for the database
  • Docker of course

Install

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 --minify

Usage

This 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 :

oblique

You can then navigate to http://0.0.0.0:9810/ and try the application.

Use this template

To use this template, click the button "Use this template" :

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

Docker

oblique provides a Dockerfile, so it's super easy to run.

First, clone the repository :

git clone https://github.com/astariul/oblique.git
cd clothion

Then create the database with alembic :

mkdir ~/data
pip install alembic
OBLIQUE_DB_PATH="~/data/oblique.sql" alembic upgrade head

And 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" oblique

Contribute

To contribute, install the package locally, create your own branch, add your code (and tests, and documentation), and open a PR !

Pre-commit hooks

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 install

Then 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-files

Tests

When 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 :

pytest

Tests 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=html

And then open the file htmlcov/index.html with your browser.

Documentation

The documentation should be kept up-to-date. You can visualize the documentation locally by running :

mkdocs serve

About

A template for building webapps with Python

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

Generated from astariul/pytere