Skip to content

Instantly share code, notes, and snippets.

@magnunleno
Created April 24, 2021 19:50
Show Gist options
  • Save magnunleno/8dad91f133a22322250d6cb609792597 to your computer and use it in GitHub Desktop.
Save magnunleno/8dad91f133a22322250d6cb609792597 to your computer and use it in GitHub Desktop.
Flask CORS + NGROK demo
#!/usr/bin/env python
import logging
from flask import Flask, jsonify
from flask_cors import CORS
from flask_ngrok import run_with_ngrok
app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
logging.getLogger('flask_cors').level = logging.DEBUG
CORS(app)
run_with_ngrok(app)
@app.route("/return_json", methods=["POST"])
def returnJson():
return jsonify({
'folder_id': 'yoyo',
'img': 'adad',
'imgname': 'bibi',
'imguniquename': 'kaka'
})
@app.route("/", methods=["GET"])
def index():
return jsonify({'msg': 'success'})
if __name__ == '__main__':
app.run()
@magnunleno
Copy link
Author

Fetched with fetch('https://89a421232651.ngrok.io/return_json', {method: 'POST' }).then(console.log)

Browser Response:
return_json_200_response

Browser request status:
return_json_200_status

NGROK inspect
return_json_200_ngrok_introspect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment