This project is about an api which receives a request width a slug as city name and sends a
request for OpenWeatherMap web service , after getting back the result it saves its into database.
- openweatherapi which sends request to the OpenWeatherMap
- wather Django app which parse re sponses and savethem in the database.
- Test section which does unittest different parts of project.
- If you os is Ubuntu there is a virtualenv ready which you can activate it by following command:
source venv/bin/activate
otherwise it's better to create your own virtualenv 2. Setup project with bellow command:
python3 setup.py install
- got to the root project directory
cd mysite
- Run Django
python manage.py runserver
1.You can send request to the following list :
http://localhost:8000/weather/{cityName}
Example:
http://localhost:8000/weather/berlin
For test i decided to use pytest.For unittest use following commands to run different
tests.
Please got to mysite/tests folder
1.Testing OpenWaather webservice connection:
python -m pytest openapi_test.py
2.Testing wather Django api :
python -m pytest weather_api_test.py
3.Testing data entry to database:
python3 -m pytest database_test.py
For Login to Django Admin Panel http://localhost/admin
Username: "Amir"
Password: "Eddy@747" (Eddy is my lovely dog)
- Django(a high-level Python web framework that encourages rapid development and clean, pragmatic design.)
- Python Programming Language
- Django Rest Framework for designing a restful application
- Numpy library to create a uniform array for get temperature
Dockerized the project and create two containers for database and rest of project and also I like to use my favourite database Postgres instead of sqlite.