Private-Google / app.py
KingNish's picture
Create app.py
abf5754 verified
raw
history blame
1.37 kB
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)