Skip to content

Instantly share code, notes, and snippets.

@rloqvist
Created July 26, 2019 09:14
Show Gist options
  • Select an option

  • Save rloqvist/038392c8b4cb353dd57dd9db24128adc to your computer and use it in GitHub Desktop.

Select an option

Save rloqvist/038392c8b4cb353dd57dd9db24128adc to your computer and use it in GitHub Desktop.
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