I am learning Flask and have trouble reproducing a tutorial. I am using Flask 0.10.1 on Python 3.5.1.
I have the following app, which has a small form on the 'Add' page. I would like to display in the console everything I submit through the form, but I don't get anything except a simple POST message below.
Any help appreciated. Thank you!
from flask import Flask, render_template, url_for, request
from datetime import datetime
from logging import DEBUG
app = Flask(__name__)
app.logger.setLevel(DEBUG)
bookmarks = []
def store_bookmark(url):
bookmarks.append(dict (
url = url,
user= 'constantin',
date = datetime.utcnow()
))
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html',title='TEST')
@app.route('/add',methods = ['GET','POST'])
def add():
if request.method == 'POST':
url = request.form['url']
store_bookmark(url)
app.logger.debug('stored url: ')
return render_template('add.html')
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'),404
if __name__ == '__main__':
app.run()