Commit cc482bb529aaf41093a63da16e5ec69c05aa3f4c
1 parent
fac9f334
Exists in
devel
Adiciona endpoint '/statistics'
Showing
1 changed file
with
9 additions
and
2 deletions
Show diff stats
src/TranslationServer.py
... | ... | @@ -4,6 +4,7 @@ |
4 | 4 | from flask import Flask, request, send_file, abort |
5 | 5 | from functools import wraps |
6 | 6 | from PortGlosa import traduzir |
7 | +from subprocess import check_output | |
7 | 8 | import os, argparse |
8 | 9 | |
9 | 10 | RUN_MODE=None |
... | ... | @@ -47,7 +48,7 @@ def init_mode(args): |
47 | 48 | print "# Server started in dictionary mode. Requests will be accepted for translation of texts and download bundles.\n# Endpoints '/translate' and '/sign' are available." |
48 | 49 | elif RUN_MODE == "full": |
49 | 50 | full_mode() |
50 | - print "# Server started in full mode. Requests will be accepted for translation of texts, download bundles. All bundles requests will be stored in a database.\n# Endpoints '/translate', '/sign' are available." | |
51 | + print "# Server started in full mode. Requests will be accepted for translation of texts, download bundles. All bundles requests will be stored in a database.\n# Endpoints '/translate', '/sign' and '/statistics' are available." | |
51 | 52 | elif RUN_MODE == "translate": |
52 | 53 | print "# Server started in translation mode.\n# Only endpoint '/translate' available." |
53 | 54 | |
... | ... | @@ -106,6 +107,12 @@ def translate(): |
106 | 107 | text = request.args.get('text').encode("UTF-8") |
107 | 108 | return traduzir(text) |
108 | 109 | |
110 | +@app.route("/statistics") | |
111 | +def load_statistics_page(): | |
112 | + page_path = os.path.join(app.static_folder, "statistics") | |
113 | + php_output = check_output(["php", page_path]) | |
114 | + return php_output | |
115 | + | |
109 | 116 | @app.route("/sign", methods=['GET']) |
110 | 117 | @check_run_mode |
111 | 118 | def get_sign(): |
... | ... | @@ -120,4 +127,4 @@ if __name__ == "__main__": |
120 | 127 | parser.add_argument("--mode", help="Video title", default="translate") |
121 | 128 | args = parser.parse_args() |
122 | 129 | init_mode(args) |
123 | - app.run(host="0.0.0.0", port=int(args.port), threaded=True, debug=False) | |
124 | 130 | \ No newline at end of file |
131 | + app.run(host="0.0.0.0", port=int(args.port), threaded=True, debug=False) | ... | ... |