-
Clone the Repository:
git clone https://github.com/olenaliuby/py-fastapi-city-temperature-management-api.git
-
Set Up a Virtual Environment: Navigate to the project directory:
cd py-fastapi-city-temperature-management-api
Create a virtual environment:
- On Windows:
python -m venv venv venv\Scripts\activate
- On macOS/Linux:
python3 -m venv venv source venv/bin/activate
- On Windows:
-
Install Dependencies:
pip install -r requirements.txt
-
Environment Variables: Create a
.env
file based on.env.sample
and populate it with necessary values.API_URL=https://api.openweathermap.org/data/2.5/weather API_KEY=Your_API_Key_Here
Run the application using Uvicorn:
uvicorn main:app --reload
This starts the application on localhost:8000
.
POST /cities
: Create a new city.GET /cities
: List all cities.GET /cities/{city_id}
: Get details of a specific city.PUT /cities/{city_id}
: Update a specific city.DELETE /cities/{city_id}
: Delete a specific city.
POST /temperatures/update
: Fetch and update temperature data for all cities.GET /temperatures
: List all temperature records.GET /temperatures/{city_id}
: Get temperature records for a specific city.
- Modular Design: Separate
city
andtemperature
modules for maintainability. - ORM with SQLAlchemy for database interactions.
- City names are unique.
- Reliance on the accuracy of the OpenWeatherMap API for temperature data.
- SQLite for simplicity in a development setup.
- No authentication and authorization implemented.
- Basic error handling, with scope for more comprehensive solutions.
- More scalable database implementation.
- User authentication and authorization.
- Enhanced error handling and logging.
- Expanded city model with more details.