0
我正在学习烧瓶并且无法复制教程。我在Python 3.5.1上使用Flask 0.10.1。烧瓶请求的日志格式数据
我有以下应用程序,它在'添加'页面上有一个小窗体。我想在控制台中显示我通过表单提交的所有内容,但除了下面的简单POST消息之外,我什么也没有得到。
任何帮助表示赞赏。谢谢!
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()
我在运行服务器之前设置了FLASK_DEBUG = 1 - 作为魅力工作。谢谢! – ConstantinL
是的 - 我无法在表单中记录数据,因为我没有启用调试模式。 – ConstantinL