Spaces:
Build error
Build error
File size: 1,366 Bytes
abf5754 |
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 |
from flask import Flask, render_template, request
from eel import init, start
import requests
app = Flask(__name__, static_folder='static')
init("web") # eel will look for web folder
BASE_URL = "https://oevortex-webscout-api.hf.space"
@app.route('/')
def index():
return render_template('index.html')
@app.route('/api/suggestions')
def get_suggestions():
query = request.args.get('q')
api_endpoint = f"{BASE_URL}/api/suggestions?q={query}"
response = requests.get(api_endpoint)
response.raise_for_status() # Raise an error for bad responses
return response.json()
@app.route('/api/search')
def perform_search():
query = request.args.get('q')
timelimit = request.args.get('timelimit', 'none')
safesearch = request.args.get('safesearch', 'off')
api_endpoint = f"{BASE_URL}/api/search?q={query}&max_results=100&timelimit={timelimit}&safesearch={safesearch}"
response = requests.get(api_endpoint)
response.raise_for_status() # Raise an error for bad responses
return response.json()
@app.route('/api/answers')
def get_people_also_search():
query = request.args.get('q')
api_endpoint = f"{BASE_URL}/api/answers?q={query}"
response = requests.get(api_endpoint)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
start('index.html', mode='chrome', port=8080) |