zoukankan      html  css  js  c++  java
  • Flask Web框架

    - pip3 install flask
    - Web框架:
    - 路由
    - 视图
    - 模板渲染

    - flask中无socket,依赖 实现wsgi协议的模块: werkzeug
    - URL两种添加方式:
    方式一:
    @app.route('/xxxxxxx')
    def hello_world():
    return 'Hello World!'
    方式二:
    def index():
    return "Index"

    app.add_url_rule('/index',view_func=index)
    - 路由系统:
    - 固定
    @app.route('/x1/')
    def hello_world():
    return 'Hello World!'

    - 不固定
    @app.route('/user/<username>')
    @app.route('/post/<int:post_id>')
    @app.route('/post/<float:post_id>')
    @app.route('/post/<path:path>')
    @app.route('/login', methods=['GET', 'POST'])

    @app.route('/xx/<int:nid>')
    def hello_world(nid):
    return 'Hello World!'+ str(nid)

    - 自定制正则
    @app.route('/index/<regex("d+"):nid>')
    def index(nid):
    return 'Index'

    - 视图

    - 模板

    - message

    - 中间件

    - Session
    - 默认:加密cookie实现
    - 第三方:Flask-Session
    redis: RedisSessionInterface
    memcached: MemcachedSessionInterface
    filesystem: FileSystemSessionInterface
    mongodb: MongoDBSessionInterface
    sqlalchemy: SqlAlchemySessionInterface

    - 蓝图(文件夹的堆放)

    - 安装第三方组件:
    - Session: Flask-Session
    - 表单验证:WTForms
    - ORM: SQLAchemy
    参考博客:http://www.cnblogs.com/wupeiqi/articles/7552008.html
    4. Tornado
    - pip3 install tornado


    参考博客:http://www.cnblogs.com/wupeiqi/articles/5702910.html

  • 相关阅读:
    2018.11.5 Nescafe26 T1 小猫爬山
    2018.10.30 NOIp模拟赛T2 数字对
    2018.10.30 NOIp模拟赛 T1 改造二叉树
    2018/7/16 YMOI模拟 NOIP2013D2T3华容道
    数据结构实验
    我的第一个博客
    题解 P5035 【金坷垃】
    题解 P5036 【随机生成树】
    题解 P5037 【抓捕】
    题解 P1328 【生活大爆炸版石头剪刀布】
  • 原文地址:https://www.cnblogs.com/menglingqian/p/8525251.html
Copyright © 2011-2022 走看看