29 lines
943 B
Python
29 lines
943 B
Python
from flask import Flask, render_template, request, redirect, url_for
|
|
from search import search_site, get_video_url
|
|
|
|
app = Flask(__name__)
|
|
app.config['SECRET_KEY'] = 'hjshjhdjah kjshkjdhjs'
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template('index.html', results=None)
|
|
|
|
@app.route('/search', methods=['GET', 'POST'])
|
|
def search():
|
|
if request.method == 'POST':
|
|
search_query = request.form['search_query']
|
|
print("Search Query:", search_query)
|
|
elif request.method == 'GET' and 'search_query' in request.args:
|
|
search_query = request.args['search_query']
|
|
results = search_site(search_query)
|
|
return render_template('index.html', results=results, query = search_query)
|
|
else:
|
|
return redirect(url_for('index'))
|
|
|
|
@app.route('/video/<path:href>')
|
|
def video(href):
|
|
return redirect(get_video_url(href))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0") |