Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,38 @@
|
|
1 |
from flask import Flask, render_template, request
|
2 |
-
from eel import init, start
|
3 |
import requests
|
4 |
|
5 |
-
app = Flask(__name__
|
6 |
-
init("web") # eel will look for web folder
|
7 |
|
8 |
-
BASE_URL = "https://oevortex-webscout-api.hf.space"
|
9 |
|
10 |
-
@app.route(
|
11 |
def index():
|
12 |
-
return render_template(
|
13 |
|
14 |
-
@app.route(
|
15 |
def get_suggestions():
|
16 |
-
|
17 |
-
api_endpoint = f"{BASE_URL}/api/suggestions?q={
|
18 |
response = requests.get(api_endpoint)
|
19 |
-
response.raise_for_status() # Raise an error for bad responses
|
20 |
return response.json()
|
21 |
|
22 |
-
@app.route('/api/search')
|
23 |
-
def perform_search():
|
24 |
-
query = request.args.get('q')
|
25 |
-
timelimit = request.args.get('timelimit', 'none')
|
26 |
-
safesearch = request.args.get('safesearch', 'off')
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
response = requests.get(api_endpoint)
|
30 |
-
response.raise_for_status() # Raise an error for bad responses
|
31 |
return response.json()
|
32 |
|
33 |
-
@app.route(
|
34 |
def get_people_also_search():
|
35 |
-
|
36 |
-
api_endpoint = f"{BASE_URL}/api/answers?q={
|
37 |
response = requests.get(api_endpoint)
|
38 |
-
response.raise_for_status()
|
39 |
return response.json()
|
40 |
|
|
|
41 |
if __name__ == "__main__":
|
42 |
-
|
|
|
1 |
from flask import Flask, render_template, request
|
|
|
2 |
import requests
|
3 |
|
4 |
+
app = Flask(__name__)
|
|
|
5 |
|
6 |
+
BASE_URL = "https://oevortex-webscout-api.hf.space"
|
7 |
|
8 |
+
@app.route("/", methods=["GET", "POST"])
|
9 |
def index():
|
10 |
+
return render_template("index.html")
|
11 |
|
12 |
+
@app.route("/api/suggestions", methods=["GET"])
|
13 |
def get_suggestions():
|
14 |
+
search_query = request.args.get("q")
|
15 |
+
api_endpoint = f"{BASE_URL}/api/suggestions?q={search_query}"
|
16 |
response = requests.get(api_endpoint)
|
|
|
17 |
return response.json()
|
18 |
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
@app.route("/api/search", methods=["GET"])
|
21 |
+
def perform_search():
|
22 |
+
search_query = request.args.get("q")
|
23 |
+
time_limit = request.args.get("timelimit", "none")
|
24 |
+
safe_search = request.args.get("safesearch", "off")
|
25 |
+
api_endpoint = f"{BASE_URL}/api/search?q={search_query}&max_results=100&timelimit={time_limit}&safesearch={safe_search}"
|
26 |
response = requests.get(api_endpoint)
|
|
|
27 |
return response.json()
|
28 |
|
29 |
+
@app.route("/api/answers", methods=["GET"])
|
30 |
def get_people_also_search():
|
31 |
+
search_query = request.args.get("q")
|
32 |
+
api_endpoint = f"{BASE_URL}/api/answers?q={search_query}"
|
33 |
response = requests.get(api_endpoint)
|
|
|
34 |
return response.json()
|
35 |
|
36 |
+
|
37 |
if __name__ == "__main__":
|
38 |
+
app.run(debug=True)
|