Python APIs using Django Rest Framework to acquire the Weather Forecast (from OpenWeather)
http://<domain>/weather/<operation>/lewisham/<date>/<time>/
You can select:
- operation - Types of operations supported (summary, temperature, pressure, humidity)
- date - Day of the forecast with the format YYYYMMDD
- time - Time of the forecast with the format HHMM (currently the forecasts are separated between 3h e.g: 0900, 1200, 1500, 1800, 2100)
http://localhost:8000/weather/summary/lewisham/20180729/1800/ http://localhost:8000/weather/summary/lewisham/20180727/0900/ http://localhost:8000/temperature/summary/lewisham/20180729/1800/
git clone https://github.com/xmaps/weather_forecast.git
cd weather_forecast/
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:$PWD" -w="$PWD" docker/compose:1.22.0 up
The container is now running and it's possible to check the logs of the requests
- Go to
http://localhost:8000/weather/summary/lewisham/20180729/1800/
CTRL/CMD+C to stop the container
echo alias docker-compose="'"'docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD:$PWD" -w="$PWD" docker/compose:1.2.0'"'" >> ~/.bashrc
source ~/.bashrc
docker-compose start
runs the service on the backgrounddocker exec -ti dg01 bash
to enter the command line inside the container- To run the tests:
python manage.py behave
docker-compose stop
stops the service
pip install docker-compose
cd weather_forecast/
- For first time running the containers
run docker-compose up -d
anddocker-compose build
for the rebuilds
The container is now running
- Go to
http://localhost:8000/weather/summary/lewisham/20180729/1800/
docker exec -ti dg01 bash
to enter the command line inside the container- To run the tests:
python manage.py behave
docker-compose stop
stops the service
- docker rm $(docker ps -a -q)# Delete all containers
- docker rmi $(docker images -q) # Delete all images
Note: This steps should be executed inside a virtual environment
cd weather_forecast/
pip install -r config/requirements.pip
cd src/
python manage.py makemigrations
python manage.py makemigrations weather
python manage.py migrate
python manage.py import_data ../config/lewisham-forecast.json
python manage.py runserver
- Go to
http://localhost:8000/weather/summary/lewisham/20180729/1800/
Note: To run this locally you need to go to the /weatherforecst/setting.py file and change the ALLOWED_HOSTS = ['web']
to ALLOWED_HOSTS = ['*']
(don't do this in production)
- To run the tests:
python manage.py behave