Skip to main content

This project represents sample of asynchronous weather REST API that is build using **quart** (flask compatible API) python web microframework based on Asyncio

Project description

made-with-python Code style: black GitHub version Build Status Coverage Status

Forks Stars Issues GitHub watchers GitHub contributors

PyPI version shields.io PyPI pyversions License

Async weather API

This project represents sample of asynchronous weather REST API that is build using quart (flask compatible API) python web microframework based on Asyncio.

Tools

Usage

Please run following script to obtain latest package from PYPI:

 pip install async-weather-api

Then please execute instructions below to launch game from your environment:

import weather

weather.run(key="your-secret-key", bind="0.0.0.0:5001", debug=False)
Running on https://0.0.0.0:5001 (CTRL + C to quit)
...

Note key stands for API key from https://openweathermap.org

Endpoints

  • / - home page
      curl -X GET http://0.0.0.0:5001/   curl -X GET http://0.0.0.0:5001/index 
    
    Response: html page
  • /api/weather/{city}/{state}/{country} - current weather event
      curl -X GET http://0.0.0.0:5001/api/events/London/GB/GreatBritain
    
    Response: json object
    {"city":"London","country":"GreatBritain","name":"Jeff the player","state":"GB"}
    
  • /api/weather/{zip_code}/{country} - current weather in city
      curl -X GET http://0.0.0.0:5001/api/weather/97002/us
    
    Response: json object
    {"base":"stations","clouds":{"all":90},"cod":200,"coord":{"lat":45.23,"lon":-122.8},
    ...}
    
  • /api/sun/{zip_code}/{country} - current sunset/sunrise in city
      curl -X GET http://0.0.0.0:5001/sun/weather/97002/us
    
    Response: json object
    {"astronomical_twilight_begin":"04:03:49 PM","astronomical_twilight_end":"04:29:50 AM",
    ...}
    

Development notes

Run from source code

To be able to run source code please execute command below:

 python -m weather run --bind 0.0.0.0:5001 --mode prod --key your-secret-key
Running on https://0.0.0.0:5001 (CTRL + C to quit)
...

CI

Project has Travis CI integration using .travis.yml file thus code analysis (black, mypy, pydocstyle, pylint, flake8) and unittests (pytest) will be run automatically after every made change to the repository.

To be able to run code analysis, please execute command below:

 ./analyse-code.sh

Also test-report.html will be generated after unittests execution.

Release notes

  • 0.4.0
    • Introduce PYPI package
  • 0.3.0
    • Introduce asynchronous approach
  • 0.2.0
    • Introduce synchronous approach
  • 0.1.0
    • Distribute initial project version

Meta

Author – Volodymyr Yahello

Distributed under the MIT license. See LICENSE for more information.

You can reach out me at:

Contributing

  1. clone the repository
  2. configure Git for the first time after cloning with your name and email
  3. pip install -r requirements.txt to install all project dependencies
  4. pip install -r requirements-dev.txt to install all development project dependencies

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async-weather-api-0.4.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

async_weather_api-0.4.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file async-weather-api-0.4.0.tar.gz.

File metadata

  • Download URL: async-weather-api-0.4.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for async-weather-api-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0e40f9219c384853387a7d3981bf0696ecf2a023e62f36d65d54f57424c1ca59
MD5 2bc776a118a1631282250e8f7964bee7
BLAKE2b-256 86ca160569f479f30dfa2f0538c29a0e01067017d95368243f542b83e280c7a9

See more details on using hashes here.

File details

Details for the file async_weather_api-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: async_weather_api-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

File hashes

Hashes for async_weather_api-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43d4f09876c694f82ebaa17e04981232a784767b29a2c05e33bd01315d5d2e62
MD5 eae313d17405e5004f174d3ce3fae16f
BLAKE2b-256 3ae574396e8ee42d8c94e242d37f9e266f2ccef54c71bacb9a4db737eeee093f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page