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

  • 相关阅读:
    HDU3555:Bomb
    入门OJ:售货员的难题
    Zju1100 Mondriaan
    与图论的邂逅08:树上倍增
    入门OJ:八中生成树2
    Poj2286 The Rotation Game
    P1379 八数码难题
    [SCOI2005]骑士精神
    与图论的邂逅07:K短路
    [Usaco2007 Feb]Cow Party
  • 原文地址:https://www.cnblogs.com/menglingqian/p/8525251.html
Copyright © 2011-2022 走看看