Created
April 24, 2021 19:50
-
-
Save magnunleno/8dad91f133a22322250d6cb609792597 to your computer and use it in GitHub Desktop.
Flask CORS + NGROK demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fetched with
fetch('https://89a421232651.ngrok.io/return_json', {method: 'POST' }).then(console.log)
Browser Response:

Browser request status:

NGROK inspect
