flaskr遇到的问题有哪些,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
drop table if exists entries;
create table entries (
id integer primary key autoincrement,
title string not null,
text string not null
);
原因: 第一行entries 后面忘了分号;
@app.route('/login', methods=['GET','POST'])
def login():
error = None
if request.method == 'POST':
if request.form['username'] != app.config['USERNAME']:
error = 'Invalid username'
elif request.form['password'] != app.config['PASSWORD']:
error = 'Invalid password'
else:
session['logged_in'] = True
flash('You were logged in')
return redirect(url_for('show_entries'))
return render_template('login.html', error=error)
错误: 显示没有函数返回值; 原因 : 没有注重格式,将 return 语句写在了上一层作用域内;
def init_db():
with app.app.context():
db = get_db()
with app.open_resource('schema.sql', mode='r') as f:
db.cursor().executescript(f.read())
db.commit()
原因:将app.app_context() 写成了 app.app.context(),所以它没办法识别app;
用 brewbrew 终端,先执行 brew uninstall python ,r然后再执行 brew install python ;
再执行 python,显示出来的就是python3的版本信息了。
在做 flask 官网中flask-tutorial 时遇到的问题
` export FLASK_APP=flaskr
export FLASK_ENV=development
flask run `
解决:将 flask run 换成 python -m flask run
关于flaskr遇到的问题有哪些问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。
原文链接:https://my.oschina.net/hyzccc/blog/3072813