This project is a simple FastAPI application integrated with htmx for building dynamic, interactive web pages.
The project includes configurations for code formatting, linting, import sorting, and type checking using popular tools like black
, flake8
, isort
, and mypy
.
- Getting Started
- Running the Project
- Formatting Code
- Linting Code
- Sorting Imports
- Type Checking
- Running Tests
- Python 3.9 or higher
pip
(Python package installer)
-
Clone the repository:
git clone https://github.com/MichaelStaHelena/fastapi-htmx-experiments.git cd fastapi-htmx-experiments
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install dependencies:
pip install -r requirements.txt
To run the FastAPI application, use fastapi dev
:
fastapi dev main.py --reload --port=8081
The application will be accessible at http://127.0.0.1:8081
.
Install the tools:
pip install black flake8 flake8-pyproject isort mypy
This project uses black
for code formatting. To format the code, run:
black .
flake8
is used for linting the code. To check for linting issues, run:
flake8 .
isort
is used to sort imports. To sort imports in the project, run:
isort .
mypy
is used for type checking. To check for type issues, run:
mypy .
If you have tests, you can run them using pytest
. To run tests, execute:
pytest