Created
July 26, 2019 09:14
-
-
Save rloqvist/038392c8b4cb353dd57dd9db24128adc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from tkinter import * | |
| from tkinter import filedialog | |
| from flask import Flask, request, jsonify | |
| from flask_cors import cross_origin | |
| root = Tk() | |
| filename = root.filename = filedialog.askopenfilename(initialdir="/home/rloqvist/Documents/json/", title="What json file would you like to serve") | |
| with open(filename, 'r') as handle: | |
| json = handle.read() | |
| root.destroy() | |
| app = Flask(__name__) | |
| @app.route('/', defaults={'path': 'z'}, methods=["GET", "POST"]) | |
| @app.route('/<path:path>') | |
| @cross_origin() | |
| def index(path): | |
| if request.method == "POST": | |
| print(request.args) | |
| print(request.get_json()) | |
| return jsonify({"status": "ok"}) | |
| return json | |
| app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment