Skip to content

The API for a fullstack project with Django and Nuxtjs that polls http://api.openweathermap.org hourly

Notifications You must be signed in to change notification settings

DavTho1983/WeatherAPI

Repository files navigation

To run this project:

I used RabbitMQ as the broker, and connected to the default at

amqp://guest:**@127.0.0.1:5672//.

so I didn't need to specify a username or password for rabbit. I used Windows 10, so I did need to install Erlang as admin and then install RabbitMQ via the Bintray link.

Install Erlang

https://www.erlang.org/downloads

Install RabbitMQ

https://www.rabbitmq.com/install-windows.html

Celery > 4.1 does not work with Windows 10 properly, so I used eventlet.

Cloning the repo

In a Mac terminal or Windows Powershell, cd into the directory where you want to put the project and use:
git clone https://github.com/DavTho1983/WeatherAPI.git

Now immediately cd into Weather

cd Weather

Creating a superuser

To use the admin section you will need to create a superuser with:

python manage.py createsuperuser

Running the Worker

In a separate terminal, cd into Weather and, run the celery worker with:

celery -A Weather worker -l info -P eventlet

Start celerybeat

This project uses django-celery-beat to schedule periodic tasks. In a separate terminal, cd into Weather and start the celerybeat scheduler with:

celery -A Weather beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler

Run the development server

To serve the project backend use:
python manage.py runserver

Navigate to the api

Open up your browser and navigate to

localhost:8000/api

The scheduler should update the LondonWeather model immediately and once at the start of every hour.

Uncommenting line 23 in Weather/celery.py will schedule a task for every 10 secs so you can see more data.

About

The API for a fullstack project with Django and Nuxtjs that polls http://api.openweathermap.org hourly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages