Production config management for any backend — centralized config module, env vars, no hardcoded secrets, fail-fast validation
86
77%
Does it follow best practices?
Impact
100%
1.88xAverage score across 5 eval scenarios
Passed
No known issues
Build a Python Flask API that aggregates weather data from the OpenWeatherMap API and caches results in Redis. The frontend team will consume this API.
Endpoints:
GET /api/weather/:city -- get current weather for a city (cached for 10 minutes)GET /api/weather/:city/forecast -- get 5-day forecast (cached for 30 minutes)GET /api/weather/favorites -- get weather for all favorited citiesPOST /api/weather/favorites -- add a city to favorites (stored in SQLite)DELETE /api/weather/favorites/:city -- remove a city from favoritesBusiness rules:
Use requests for HTTP calls, redis for caching, and sqlite3 for favorites storage.
Produce:
app/__init__.py -- Flask application factoryapp/routes/weather.py -- weather route handlersapp/routes/favorites.py -- favorites route handlersapp/weather_client.py -- OpenWeatherMap API integrationapp/cache.py -- Redis cache layerapp/db.py -- SQLite database setuprequirements.txt -- with dependencies.gitignore -- standard Python gitignoreYou may create additional files as needed for a well-structured codebase.