A python boilerplate for fastapi and streamlit projects.
Project description
Sample-py
A streamlit, fast api boilerplate for python development
Installation Guide
Prerequisites
- Python ≥ 3.11
- Poetry ≥ 2.2.1
- Streamlit ≥ 1.49.1
Getting Started
Poetry Setup
curl -sSL https://install.python-poetry.org | python3 -
# OR
pip install poetry>=2.2.1
Virtual Environment Configuration
poetry config virtualenvs.path /your/desired/path
Ensure below files are configured (create if not exist) properly to run the project;
.env.development.env.production
Install Dependencies
poetry lock --no-cache --regenerate
poetry install --all-extras --with dev
Or manually
make install
How to Run
Configure ENVIRONMENT
setup .env.development and .env.production in project root
# for local configuration(linux)
export ENV=development
# for production(linux)
export ENV=production
Run Streamlit App
make dev
#or with custom port
poetry run sample dev --port 8051
then open UI on : http://localhost:8501
to run on different port use --port option
poetry run sample dev --port 1234
Run FastAPI Server
make api
#OR with custom port
poetry run sample api --port 5000
Access: http://127.0.0.1:5000
🧹 Linting & Code Quality
Pre-commit hooks are enabled. If commits fail, run:
make lint
or run individual
poetry run black .
poetry run flake8 .
poetry run mypy .
poetry run ruff check .
Build & Packaging
Build Package
poetry clean
poetry build
Artifacts in dist/
- sample-x.y.0-py3-none-any.whl
- sample-x.y.0.tar.gz
Test Locally
python -m venv .venv-dist
source .venv-dist/bin/activate
# Windows
.venv-dist\Scripts\activate
Install package
pip install dist/*.whl
pip install --upgrade dist/*.whl
# Install extras:
pip install sample
CLI Shortcuts
make dev → Launch Streamlit UI
make api → Launch FastAPI
current version will be printed on start of above commands.
Install GIT hooks
these hooks will
- Check for lint and audit for security before commit
- Append branch name in commit message
- Generate requirements.txt on checkout on new branch
# Install git hooks
make hooks
there is .vscode/Python.code-profile file; import this as a profile in vscode which include necessary extension for python development.
Troubleshooting
sometimes there might be chances that virtual environment get corrupted then delete the old virtual environment and start afresh.
poetry env info
# this will provide virtual environment name
poetry env remove <environment-full-name>
License
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rz_sample-2.0.1.tar.gz.
File metadata
- Download URL: rz_sample-2.0.1.tar.gz
- Upload date:
- Size: 110.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40f88347d9ea5b7c807b1d6edaa778bac18bdce8cde5caddd24684b7dae70ecd
|
|
| MD5 |
5e6213307fd0d3ec3447dc11fa500418
|
|
| BLAKE2b-256 |
43a3d75f6e454968830ce581ff9a39c4f66cee031da25143ad9c2640342d46ca
|
File details
Details for the file rz_sample-2.0.1-py3-none-any.whl.
File metadata
- Download URL: rz_sample-2.0.1-py3-none-any.whl
- Upload date:
- Size: 114.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a2a9e3ece8fb1e2e0bc5d779617e19cd7464a91ad27ee11118be9f9a50ef4bd
|
|
| MD5 |
0391a9e6fd4660e559e8b0f217c02c83
|
|
| BLAKE2b-256 |
f533adf470a4166085034fb35c40d0b0667bcee0a852e7b8e9dbc47d529ac6c1
|