摘要: 定义评论的视图函数@app.route('/comment/',methods=['POST'])def comment():读取前端页面数据,保存到数据库中 用<input type="hidden" 方法获取前端的"question_id" 显示评论次数 要求评论前登录 尝试实现详情页面下的评论 阅读全文
posted @ 2017-12-08 10:07 003刘淑千 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 主PY文件写视图函数,带id参数。 首页标题的标签做带参数的链接。 {{ url_for('detail',question_id = foo.id) }} 在详情页将数据的显示在恰当的位置。 建立评论的对象关系映射: class Comment(db.Model): __tablename__=' 阅读全文
posted @ 2017-12-05 15:00 003刘淑千 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 首页列表显示全部问答: 完成问答详情页布局: 阅读全文
posted @ 2017-12-01 20:37 003刘淑千 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 1. 在首页添加显示问答的列表,并定义好相应的样式。 无序列表 <ul > <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> 2. 用字典向index.html传递参数。 阅读全文
posted @ 2017-11-29 15:57 003刘淑千 阅读(83) 评论(0) 推荐(0) 编辑
摘要: 编写要求登录的装饰器 from functools import wraps def loginFirst(func): #参数是函数 @wraps(func) def wrapper(*args, ** kwargs): #定义个函数将其返回 #要求登录 return func(*args, ** 阅读全文
posted @ 2017-11-28 09:58 003刘淑千 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 用上下文处理器app_context_processor定义函数 获取session中保存的值 返回字典 在父模板中更新导航,插入登录状态判断代码。、 注意用{% ... %}表示指令。 {{ }}表示变量 完成注销功能。 清除session 跳转 阅读全文
posted @ 2017-11-24 09:57 003刘淑千 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 登录功能完成: session: 阅读全文
posted @ 2017-11-21 12:32 003刘淑千 阅读(851) 评论(0) 推荐(0) 编辑
摘要: html文件: def regist(): if request.method == 'GET': return render_template('regist.html') else: username = request.form.get(‘username’)#获取form中的数据 判断用户名 阅读全文
posted @ 2017-11-17 20:27 003刘淑千 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 增 改 删 阅读全文
posted @ 2017-11-15 15:46 003刘淑千 阅读(111) 评论(0) 推荐(0) 编辑
摘要: mysql: https://dev.mysql.com/downloads/mysql/ MySQL-python 中间件:https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python pip install mysqlclient-1.3.12 阅读全文
posted @ 2017-11-14 10:03 003刘淑千 阅读(155) 评论(0) 推荐(0) 编辑