Skip to main content

A restcountries API wrapper for Flask Applications.

Project description

Requirements Status Codacy Badge Coverage Status

Flask-RestCountries

Flask-RestCountries provides a simple intergration for restcountries.eu API with Flask Applications.

Installation

Use the package managerpip to install flask-restcountries.

pip install Flask-RestCountries

Usage

from flask import Flask
from flask_restcountries import CountriesAPI

app = Flask(__name__)


rc = CountriesAPI(app)

if you are using blueprints

from flask_restcountries import CountriesAPI
rc = CountriesAPI()

rc.init_app(app)

Usage in App

@app.route('/get-all')
def get_all_countries():
    """all_countries is a list of Country Objects"""
    all_countries = rc.get_all()
    return render_template("example.html", all_countries=all_countries)

Other Useful Methods

Get Countries By Calling Code string of a country. E.g. '254'.

countries=rc.get_countries_by_calling_code("+254")

Get a Country By Alpha code string of a country. E.g. 'ke'.

countries=rc.get_country_by_country_code("ke")

Get Countries By Capital string of a country. E.g. 'Nairobi'

countries=rc.get_countries_by_capital("Nairobi")

Get Countries By Currency string of a country. E.g. 'KES'.

countries=rc.get_countries_by_currency("KES")

Get Countries By Language string of a country. E.g. 'sw'.

countries=rc.get_countries_by_language("sw")

Get Countries By Name string of a country. E.g. 'Kenya'.

countries=rc.get_countries_by_name("Kenya")

Get Countries By Region string of a country. E.g. 'Africa'.

countries=rc.get_countries_by_region("Africa")

Get Countries By Subregion string of a country. E.g. 'Eastern Africa'

countries=rc.get_countries_by_subregion("Eastern Africa")

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Tests and Examples

Examples are comming soon!.

License

MIT

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

Flask-RestCountries-1.1.2.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file Flask-RestCountries-1.1.2.tar.gz.

File metadata

  • Download URL: Flask-RestCountries-1.1.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

File hashes

Hashes for Flask-RestCountries-1.1.2.tar.gz
Algorithm Hash digest
SHA256 8942d1d4d0033d0466c77a7be784e409cbd84958b89f0fbf8c990f4869f71302
MD5 fe82090a7dcc1c1e7369da3809ea9940
BLAKE2b-256 45001886dc2b0f6a3d9e450d9e99a681a941579988cc54dc34a5fe0263766fd3

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