This project integrates a Flask backend with a Streamlit frontend, using a shared Python virtual environment for dependency management and pytest for testing.
flask-streamlit-app/
├── backend/
│ ├── app.py
│ ├── requirements.txt
│ └── tests/
│ └── test_app.py
├── frontend/
│ ├── app.py
│ ├── requirements.txt
│ └── tests/
│ └── test_app.py
├── .venv/
└── README.md
-
Create and activate the virtual environment:
python3 -m venv .venv source .venv/bin/activate -
Install dependencies for both backend and frontend:
pip install -r backend/requirements.txt pip install -r frontend/requirements.txt
- Activate the virtual environment if not already active:
source .venv/bin/activate - Start the backend server:
The backend will run at
python3 backend/app.py
http://localhost:5000/.
- Activate the virtual environment if not already active:
source .venv/bin/activate - Start the frontend app:
The frontend will run at
streamlit run frontend/app.py
http://localhost:8501/.
- The frontend sends POST requests to the backend endpoint
/api/data. - The backend receives the data and responds with a JSON object.
- Tests are written using
pytestand placed in thetests/folders in both backend and frontend. - To run all tests:
cd backend && pytest cd ../frontend && pytest
- All dependencies are managed in a single virtual environment (
.venv). __pycache__folders are auto-generated by Python for bytecode caching and can be ignored.- Make sure both backend and frontend servers are running for full integration.