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

  • 相关阅读:
    pandas.DataFrame.to_excel
    python list [:1]
    python 读取文件
    pandas 中的常用数学计算
    神经网络相关术语
    keras初探
    机器学习相关
    Numpy random arange zeros
    numpy 常用函数
    【Redis学习之四】Redis数据类型 string
  • 原文地址:https://www.cnblogs.com/menglingqian/p/8525251.html
Copyright © 2011-2022 走看看