1

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!

enter image description here

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()
davidism
  • 121,510
  • 29
  • 395
  • 339
cnstlungu
  • 547
  • 1
  • 9
  • 22

1 Answers1

1

The documentation states:

If the application runs in production mode (which it will do on your server) you might not see any log messages.

Do you run your code in production or debug mode?

Make sure it is run in Debug mode by setting the environment variable FLASK_DEBUG to true and try again, it should then appear.