Spaces:
Sleeping
Sleeping
from flask import Flask, render_template, request | |
import requests | |
import os | |
app = Flask(__name__) | |
BASE_URL = "https://oevortex-webscout-api.hf.space" | |
def index(): | |
return render_template("index.html") | |
def get_suggestions(): | |
search_query = request.args.get("q") | |
api_endpoint = f"{BASE_URL}/api/suggestions?q={search_query}" | |
response = requests.get(api_endpoint) | |
return response.json() | |
def perform_search(): | |
search_query = request.args.get("q") | |
results = request.args.get("max_results", "10") | |
time_limit = request.args.get("timelimit", "none") | |
safe_search = request.args.get("safesearch", "off") | |
api_endpoint = f"{BASE_URL}/api/search?q={search_query}&max_results={results}&timelimit={time_limit}&safesearch={safe_search}" | |
response = requests.get(api_endpoint) | |
return response.json() | |
def get_people_also_search(): | |
search_query = request.args.get("q") | |
api_endpoint = f"{BASE_URL}/api/answers?q={search_query}" | |
response = requests.get(api_endpoint) | |
return response.json() | |
if __name__ == "__main__": | |
port = int(os.environ.get('PORT', 7860)) | |
app.run(host='0.0.0.0', port=port) |