-
Notifications
You must be signed in to change notification settings - Fork 2
/
application.py
29 lines (25 loc) · 1.04 KB
/
application.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
from flask import request, url_for
from flask_api import FlaskAPI, status, exceptions
from flask_cors import CORS
from zimmerbot import *
application = FlaskAPI(__name__)
CORS(application)
@application.route("/", methods=["GET", "POST"])
def get_links():
if request.method == "GET":
list_of_links = main("dog", "en", "popularity", "10", "include")
else:
print(request.data)
data = request.data
if data["filter"] == "ores_quality" and data["language"] not in ["en", "ru", "fr"]:
return ["ORES is not supported in this language"], status.HTTP_202_ACCEPTED
list_of_links = main(data["query"], data["language"], data["filter"], data["limit"], data["stub"])
if not list_of_links:
return ["No search results found for this query"], status.HTTP_202_ACCEPTED
return list_of_links
# run the app.
if __name__ == "__main__":
# Setting debug to True enables debug output. This line should be
# removed before deploying a production app.
# app.debug = True
application.run()