摘要:
用上下文处理器app_context_processor定义函数 获取session中保存的值 返回字典 在父模板中更新导航,插入 登录状态判断代码。 注意用{% ... %}表示指令。 {{ }}表示变量完成注销功能。 @app.context_processor def mycontext(): usern=session.get('user') if usern: ... 阅读全文
摘要:
登录功能完成: js:设置return html:设置 form input onclick="return fnLogin()" py: @app.route设置methods GET POST 读取表单数据 查询数据库 用户名密码对: 记住用户名 跳转到首页 用户名密码不对: 提示相应错误。 s 阅读全文
摘要:
def regist(): if request.method == 'GET': return render_template('regist.html') else: username = request.form.get(‘username’)#获取form中的数据 判断用户名是否存在:存在报 阅读全文
摘要:
增加:user = db.session.add(user)db.session.commit() 查询:User.query.filter(User.username == 'mis1114').first() 修改:user.password = '111111'db.session.commit() 删除:db.session.delete(user)db.session.commit() ... 阅读全文
摘要:
安装与配置python3.6+flask+mysql数据库 下载安装MySQL数据库 下载安装MySQL-python 中间件 pip install flask-sqlalchemy (Python的ORM框架SQLAlchemy) mysql创建数据库 数据库配置信息config.py 建立mysql和app的连接 创建用户模型 from flask import Flask from ... 阅读全文
摘要:
带label的文本输入区域 阅读全文
摘要:
用url_for加载静态文件 <script src="{{ url_for('static',filename='js/login.js') }}"></script> flask 从static文件夹开始寻找 可用于加载css, js, image文件 继承和扩展 把一些公共的代码放在父模板中, 阅读全文
摘要:
from flask import Flask from flask import render_template app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') @app.route('/wr') def wr(): return render... 阅读全文
摘要:
登录 首页 首页 阅读全文
摘要:
完成登录与注册页面的HTML+CSS+JS,其中的输入项检查包括: 用户名6-12位 首字母不能是数字 只能包含字母和数字 密码6-12位 注册页两次密码是否一致 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <titl 阅读全文