-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.py
71 lines (54 loc) · 1.68 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from flask import Flask, request, render_template, redirect, url_for, Response
from werkzeug import secure_filename
from utils import build_file_name
import os
from config import app
from models import Igualito
from google.appengine.ext.webapp.util import run_wsgi_app
@app.context_processor
def insertar_ultimos():
ultimos = Igualito.all()
return dict(ultimos=ultimos)
@app.route("/")
def index():
igualitos = Igualito.all()
return render_template('index.html', igualitos=igualitos )
@app.route("/upload/", methods=['POST', 'GET'])
def upload():
if request.method == 'POST':
file1 = request.files['pic1']
file2 = request.files['pic2']
filename1 = build_file_name(file1.filename)
filename2 = build_file_name(file2.filename)
data = Igualito()
data.nombre = request.form['name']
data.imagen1 = file1.read()
data.imagen2 = file2.read()
data.put()
return redirect(url_for('uploaded_end', file1=None, file2=None ))
return render_template('upload.html')
@app.route('/upload_end')
def uploaded_end():
return render_template('uploaded_file.html')
@app.route('/imagen1/<key>')
def uploaded_file(key):
igualito = Igualito.get(key)
return Response(igualito.imagen1, mimetype='image/jpeg')
@app.route('/imagen2/<key>')
def uploaded_file(key):
igualito = Igualito.get(key)
return Response(igualito.imagen2, mimetype='image/jpeg')
@app.route('/show/')
@app.route("/show/<name>")
def post(name=None):
return render_template('index.html', name=name)
@app.route("/get", methods=['POST'])
def obtener():
pass
@app.errorhandler(404)
def page_not_found(error):
return render_template('page_not_found.html'), 404
def main():
run_wsgi_app(app)
if __name__ == "__main__":
main()