Understand Flask
Service with a REST Endpoint to search for movies using genre as query parameter, as:
GET /movies?genre=Animation&offset=0&limit=10
genre: Genres are provided as a static resource in the genres.json file.
offset: Starting index for the search results. Default is 0, if not specified.
limit: Number of results returned per page. Default is 10 if not specified.
It it will query a service that runs in localhost:3040
{
"data": {
"movies": [
{ "id": "1111" }, ...
]
},
"metadata": {
"offset": 0,
"limit": 10,
"total": 20
}
}
Python version used 3.7.2
- Run movie services in
localhost:3040 - Recommended create a virtual environment, eg:
python3 -m venv ~/venv - Activate virtual env, eg:
source ~/venv/bin/activate - Install requirements
pip install -r requirements.txt - Run app
python main.py, app opened in http://localhost:5000 - Run tests
python test_movies.py
- Activated virtual env
- App running
locust --host=http://localhost:5000 -f test_performance.py- Open browser http://localhost:8089