-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.py
43 lines (33 loc) · 1.38 KB
/
homepage.py
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
43
from flask import Flask, request, session, g, redirect, url_for, \
abort, render_template, flash
from contextlib import closing
import requests, json
import random
from movierama import actions
app = Flask(__name__)
app.config.from_object(__name__)
@app.route('/')
def start_page(query="start_page", page=1):
results, pages, total = actions.search(query)
return render_template('home.html', results=results, total=total, query_text=query, page=page, pages=pages)
@app.route('/<query>/<page>', methods=['GET', 'POST'])
def show_entries(query="", page=1):
if request.method == 'POST':
query = request.form["search-text"]
results, pages, total = actions.search(query)
return render_template('search.html', results=results, total=total, query_text=query, page=page, pages=pages)
@app.route('/search', methods=['POST'])
def search():
if request.method == 'POST':
query = request.form["search-text"]
results, pages, total = actions.search(query)
return render_template('search.html', results=results, total=total, query_text=query, page=1)
@app.route('/page', methods=['POST'])
def get_page():
if request.method == 'POST':
page = int(request.form["page"])
query_text = request.form["query_name"]
print query_text
return redirect('/'+query_text+'/'+int(page))
if __name__ == '__main__':
app.run(port=5555)