摘要: 定义评论的视图函数@app.route('/comment/',methods=['POST'])def comment():读取前端页面数据,保存到数据库中 @app.route('/comment/',methods=['POST']) @loginFirst def comment(): comment=request.form.get('new_comment') qu... 阅读全文
posted @ 2017-12-08 10:51 041覃楚君 阅读(128) 评论(0) 推荐(0)
摘要: 2. 3. 阅读全文
posted @ 2017-12-05 09:10 041覃楚君 阅读(154) 评论(0) 推荐(0)
摘要: py: index.html: detail.html: 阅读全文
posted @ 2017-12-01 16:43 041覃楚君 阅读(128) 评论(0) 推荐(0)
摘要: 1. 在首页添加显示问答的列表,并定义好相应的样式。 无序列表 <ul > <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> 2. 用字典向index.html传递参数。 1: 2: 阅读全文
posted @ 2017-11-30 16:31 041覃楚君 阅读(135) 评论(0) 推荐(0)
摘要: 编写要求登录的装饰器 from functools import wraps def loginFirst(func): #参数是函数 @wraps(func) def wrapper(*args, ** kwargs): #定义个函数将其返回 #要求登录 return func(*args, ** 阅读全文
posted @ 2017-11-28 18:00 041覃楚君 阅读(99) 评论(0) 推荐(0)
摘要: 用上下文处理器app_context_processor定义函数 获取session中保存的值 返回字典 在父模板中更新导航,插入登录状态判断代码。、 注意用{% ... %}表示指令。 {{ }}表示变量 完成注销功能。 清除session 跳转 {% if username %} <a href 阅读全文
posted @ 2017-11-24 09:42 041覃楚君 阅读(115) 评论(0) 推荐(0)
摘要: 登录功能完成: py: 阅读全文
posted @ 2017-11-21 11:47 041覃楚君 阅读(240) 评论(0) 推荐(0)
摘要: def regist(): if request.method == 'GET': return render_template('regist.html') else: username = request.form.get(‘username’)#获取form中的数据 判断用户名是否存在 存到数 阅读全文
posted @ 2017-11-17 11:29 041覃楚君 阅读(118) 评论(0) 推荐(0)
摘要: 增加:db.session.add(user)db.session.commit() 查询:User.query.filter(User.username == 'mis1114').first() 修改:user.password = '111111'db.session.commit() 删除: 阅读全文
posted @ 2017-11-16 14:12 041覃楚君 阅读(133) 评论(0) 推荐(0)
摘要: 安装与配置python3.6+flask+mysql数据库 下载安装MySQL数据库 下载安装MySQL-python 中间件 pip install flask-sqlalchemy (Python的ORM框架SQLAlchemy) mysql创建数据库 数据库配置信息config.py 建立mysql和app的连接 创建用户模型 SQLALCHEMY_DATABASE_URI='mysq... 阅读全文
posted @ 2017-11-14 20:57 041覃楚君 阅读(109) 评论(0) 推荐(0)