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
PYPI
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
keystands for API key from https://openweathermap.org
Docker image
Please run next command to start async weather api via docker:
docker run -it -p 3000:5001 vyahello/async-weather-api:0.5.0 weather run --bind 0.0.0.0:5001 --mode prod --key <secret-key>
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)
...
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
CI/CD
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.
Other than that, a fresh versioned package will be delivered on PYPI after new tag is created using pythonpublish.yml file.
Release notes
- 0.5.0
- Add official docker image
- 0.4.2
- Add manifest package installer file
- 0.4.1
- Read requirements for PYPI build
- 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:
- vyahello@gmail.com
- https://github.com/vyahello
- https://www.linkedin.com/in/volodymyr-yahello-821746127
Contributing
- clone the repository
- configure Git for the first time after cloning with your
nameandemail pip install -r requirements.txtto install all project dependenciespip install -r requirements-dev.txtto install all development project dependencies
Metadata
Release files for async-weather-api 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| async-weather-api-0.5.0.tar.gz | 7.8 kB | Without provenance | Details for async-weather-api-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| async_weather_api-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for async_weather_api-0.5.0-py3-none-any.whl |
Total release size: 18.8 kB
Release files / async-weather-api-0.5.0.tar.gz
| Download URL | async-weather-api-0.5.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
99c1e22a5a9c5d3bf8083eef80e4243a554800fdbc6e41d3e3d94973932dc1ea
|
|
BLAKE2b-256 checksum How to use checksums |
e481a78037d7049ffdfbb19e25507d3ae25e2d4afa6391adfaaff2caa7bf21ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / async_weather_api-0.5.0-py3-none-any.whl
| Download URL | async_weather_api-0.5.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ac9ae7d2d60d4ebf05cd4890422652e175bca53d61c3b7b7ef0e0845684821f
|
|
BLAKE2b-256 checksum How to use checksums |
a1200926312b16751bf07d112a8632a19256f2c394179a205603315aa21773c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for async-weather-api 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.