Skip to content
Permalink
Browse files

save the vote and thank the voter

  • Loading branch information
szabgab committed Feb 17, 2015
1 parent 2a293a4 commit ba5a516c7e1506d7c25807ebd18e9ef388df2b9b
Showing with 25 additions and 1 deletion.
  1. +13 −1 poll.py
  2. +12 −0 templates/thankyou.html
14 poll.py
@@ -1,16 +1,28 @@
from flask import Flask, render_template
from flask import Flask, render_template, request
import os
app = Flask(__name__)

poll_data = {
'question' : 'Which web framework do you use?',
'fields' : ['Flask', 'Django', 'TurboGears', 'web2py', 'pylonsproject']
}
filename = 'data.txt'

@app.route('/')
def root():
return render_template('poll.html', data=poll_data)

@app.route('/poll')
def poll():
vote = request.args.get('field')

out = open(filename, 'a')
out.write( vote + '\n' )
out.close()

return render_template('thankyou.html', data=poll_data)


if __name__ == "__main__":
app.run(debug=True)

@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<title>{{ data.question }}</title>
</head>
<body>
<h1>Thank you for submitting your vote for</h1>
{{ data.question }}

</body>
</html>

0 comments on commit ba5a516

Please sign in to comment.
You can’t perform that action at this time.