/kkbox-api-flask-cors

Use Flask-CORS package KKBOX open api to separate front and back ends.

Primary LanguagePython

KKBOX API Flask CORS

KKBOX API Flask CORS for handling Cross Origin Resource Sharing, making cross-origin AJAX possible.

This is a simple demo at https://kk-search.herokuapp.com/search?q=Mayday&type=track&territory=TW.

Demo only provide search api.

Setting config value

  1. Change setting.cfg value
CLIENT_ID='<CLIENT_ID>'
CLIENT_SECRET='<CLIENT_SECRET>'
ALLOW_CORS_DOMAIN='http://example.com'
  1. Set environment variable
export CLIENT_ID='<CLIENT_ID>'
export CLIENT_SECRET='<CLIENT_SECRET>'
export ALLOW_CORS_DOMAIN='http://example.com'
  1. Set environment variable before run server command
CLIENT_ID='<CLIENT_ID>' CLEINT_SECRET='<CLIENT_SECRET>' ALLOW_CORS_DOMAIN='http://example.com' python server.py

Usage

  1. Simple run server
python server.py
  1. Use gunicorn run server
# default address:port = 0.0.0.0:8000
gunicorn kkbox_api:app

# specify address:port
gunicorn kkbox_api:app -b 127.0.0.1:6666
  1. Deploy to HeroKu