Fastweather is an asynchronous lightweight weather service application built with fastapi.
This service utilizes external API resources while respecting the rate-limit of the API. Although, the service is built for openweathermap API, it can easily be integrated for other external API services or any long running background task that involves I/O operation.
git clone https://github.com/collinsuzebu/fastweather.git
cd fastweather
Create a free account at Open Weather API to generate a token to call their API.
Add your API key to .env
file in the section API_OPEN_WEATHER_MAP_KEY.
MongoDB is required to run locally. When running locally and you don't want to spend extra time creating a mongoDB user, simply set the environment variable flag STRICT_DEV=true.
pip install -r requirements.txt
Setting up environment variables Include any environment variable like so:
export API_OPEN_WEATHER_MAP_KEY=your_secret_key
To run the web application in debug mode:
uvicorn fastweather.main:app --reload
You must have docker
and docker-compose
installed.
Create a mongoDB user or use an existing user.
$ use admin
> db.createUser( { user: "username", pwd: "password", roles: [ { role: "root", db: "admin" } ] } )
Create a .env
file in the root directory next to .env.sample
and specify your service
configuration. Then run the command
docker-compose up --build
Run test using coverage.py In the root directory, run the command
pip install -r requirements-dev.txt
coverage run -m pytest