-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
38 lines (32 loc) · 1.05 KB
/
server.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
"""importing for flask."""
from flask import Flask, render_template, request, redirect, flash, session
app = Flask(__name__)
app.secret_key = "sosecretive"
@app.route('/')
def home():
print 'your home'
return render_template('index.html')
@app.route('/result', methods=['POST', 'GET'])
def result():
print 'you did it'
name = request.form['name']
location = request.form['location']
language = request.form['favorite']
comments = request.form['comments']
if len(name) < 1 and len(comments) < 1:
flash('error in name')
flash('what no comments')
return redirect('/')
elif len(name) < 1:
flash('error in name')
return redirect('/')
elif len(comments) < 1:
flash('what no comments')
return redirect('/')
elif len(comments) > 120:
flash(' whoa now, please keep comments under 120 characters ')
return redirect('/')
return render_template(
'success.html', name=name, local=location,
favLang=language, comment=comments)
app.run(debug=True)