-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
43 lines (31 loc) · 1.01 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
from flask import Flask, jsonify, render_template
import sys
sys.path.append("src")
import wiki_search
APP = Flask(__name__)
APP_VERSION = "v0.1.3"
@APP.route("/")
def index():
return render_template("index.html", version=APP_VERSION)
@APP.route("/v1/version")
def v1_version():
return jsonify(app=APP, version=APP_VERSION, stable="True")
@APP.route("/v1/getinfo/<string:lang>/<string:pid>/<int:top>/")
def getinfo(pid, top, lang):
try:
(title, words_dict) = wiki_search.get_data(pid, top, lang)
return render_template(
"res.html", words_dict=words_dict, title=title, pid=pid, top=top, lang=lang
)
except TypeError:
return render_template(
"res.html", words_dict=None, title="", pid=pid, top=top, lang=lang
)
# endpoint for status
@APP.route("/v1/status")
def status():
return jsonify(status="OK")
if __name__ == "__main__":
APP.run(debug=False, port=1234)