diff options
author | ache <ache@ache.one> | 2020-11-23 03:41:54 +0100 |
---|---|---|
committer | ache <ache@ache.one> | 2020-11-23 03:41:54 +0100 |
commit | 451d7bf0db58d42afc5a5086353558d227040dff (patch) | |
tree | 3cf473a791ba425e09da566a142f9bb32da692e6 /web.py | |
parent | Documentation README (diff) |
Update everything
Diffstat (limited to 'web.py')
-rw-r--r-- | web.py | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1,3 +1,7 @@ +""" +A simple Web application to serve dicofr +""" + from flask import Flask, request, Response, send_file import msgpack # from flask_cors import CORS @@ -20,17 +24,26 @@ app.config.from_object(__name__) @app.route('/', methods=['GET']) def index_client(): + """ + Send the single file + """ return send_file("index.html", mimetype='text/html') def get_def_reg(w): + """ + Search a word, can deal with regex and casse problem. + """ if res := dicofr.get_def_sql_reg(w): return msgpack.packb(res) + # Recherche du mot en minuscule elif res := dicofr.get_def_sql_reg(w.lower()): return msgpack.packb(res) + # Recherche du mot en nom propre elif res := dicofr.get_def_sql_reg(w.title()): return msgpack.packb(res) + else: return Response("", status=404) @@ -38,6 +51,9 @@ def get_def_reg(w): @app.route('/def', methods=['GET']) def get_def(): + """ + Retrieve a definition + """ w = request.args.get('w') if '_' in w: |