• flask之请求与响应


    请求相关
    1 from flask import Flask 2 from flask import request 3 from flask import render_template 4 from flask import redirect 5 from flask import make_response 6 7 app = Flask(__name__) 8 9 10 @app.route('/login.html', methods=['GET', "POST"]) 11 def login(): 12 13 # 请求相关信息 14 # request.method 15 # request.args 16 # request.form 17 # request.values 18 # request.cookies 19 # request.headers 20 # request.path 21 # request.full_path 22 # request.script_root 23 # request.url 24 # request.base_url 25 # request.url_root 26 # request.host_url 27 # request.host 28 # request.files 29 # obj = request.files['the_file_name'] 30 # obj.save('/var/www/uploads/' + secure_filename(f.filename)) 31 32 # 响应相关信息 33 # return "字符串" 34 # return render_template('html模板路径',**{}) 35 # return redirect('/index.html') 36 37 # response = make_response(render_template('index.html')) 38 # response是flask.wrappers.Response类型 39 # response.delete_cookie('key') 40 # response.set_cookie('key', 'value') 41 # response.headers['X-Something'] = 'A value' 42 # return response 43 44 45 return "内容" 46 47 if __name__ == '__main__': 48 app.run()

     

  • 相关阅读:
    Android MVP
    Intellij Idea/Webstorm/Phpstorm 的高效快捷键
    如何在Webstorm/Phpstorm中设置连接FTP,并快速进行文件比较,上传下载,同步等操作
    前端开发利器webStorm /phpStorm
    CSS清除浮动方法集合
    14 JS基本语句
    12.8.8 可见与隐藏
    12.8 定位属性
    12.5 段落属性
    12.4 背景属性
  • 原文地址:https://www.cnblogs.com/1996-11-01-614lb/p/8975758.html
Copyright © 2020-2023  润新知