aboutsummaryrefslogtreecommitdiff
path: root/web.py
diff options
context:
space:
mode:
Diffstat (limited to 'web.py')
-rw-r--r--web.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/web.py b/web.py
index c5e0b1c..82ad696 100644
--- a/web.py
+++ b/web.py
@@ -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: