diff options
author | ache <ache@ache.one> | 2020-02-21 06:01:13 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2020-02-21 06:01:13 +0100 |
commit | d9ffc8393bcf57c8f365ad5be32b095f5c99c87e (patch) | |
tree | 85b6b0832b2b2042a9890987e119863b27712aac /web.py |
Init commit
Diffstat (limited to 'web.py')
-rw-r--r-- | web.py | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ +from flask import Flask, request, Response, send_file +import msgpack +# from flask_cors import CORS + +import dicofr + + +# configuration +DEBUG = False + +# instantiate the app +app = Flask(__name__, + static_url_path='', + static_folder='assets') +app.config.from_object(__name__) + +# enable CORS +# CORS(app, resources={r'/*': {'origins': '*'}}) + + +@app.route('/', methods=['GET']) +def index_client(): + return send_file("index.html", mimetype='text/html') + + +@app.route('/def', methods=['GET']) +def get_def(): + if res := dicofr.get_def_sql(request.args.get('w')): + return msgpack.packb(res) + else: + return Response("", status=404) + return Response(msgpack.packb(request.args.get('w')), + mimetype='application/msgpack') + + +if __name__ == '__main__': + app.run() |