-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
43 lines (35 loc) · 1.18 KB
/
application.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, render_template, jsonify, request
from database import init_db, db_session
from models import Zapatazo
app = Flask('purozapatazos')
init_db()
@app.route('/')
def main_page():
#TODO
zapatazos = db_session.query(Zapatazo).limit(12)
print "zapatazos: ", zapatazos
return render_template('index.html', zapatazos = zapatazos)
@app.route('/load_more.json')
def load_more():
offset = request.args.get('offset')
# print "offset: ", offset
zapatazos = db_session.query(Zapatazo).offset(offset).limit(12)
# print "ZAPATAZO: ", zapatazos
return jsonify(Zapatazo=[i.serialize for i in zapatazos])
@app.route('/acerca/')
def purozapatazos():
return render_template('acerca.html')
@app.route('/<int:the_number>/')
def unzapatazo(the_number):
try:
zapatazo = db_session.query(Zapatazo).filter(Zapatazo.id == the_number).one()
except Exception as e:
return render_template('404.html'), 404
# print "ZAPATAZO: ", zapatazo
return render_template('unzapatazo.html', zapatazo = zapatazo)
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404
if __name__ == '__main__':
app.debug = True
app.run(host = '0.0.0.0', port = 8000)