本文整理汇总了Python中werkzeug.Response.headers["Content-Disposition"]方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers["Content-Disposition"]方法的具体用法?Python Response.headers["Content-Disposition"]怎么用?Python Response.headers["Content-Disposition"]使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.Response
的用法示例。
在下文中一共展示了Response.headers["Content-Disposition"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __call__
# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import headers["Content-Disposition"] [as 别名]
def __call__(self, env, start_response):
Config = ConfigParser()
Config.read(configfile)
params = {"host": "", "user": "", "database": "", "port": ""}
for param in params:
if not Config.has_option("BlobStore", param):
print "Malformed configuration file: mission option %s in section %s" % (param, "BlobStore")
sys.exit(1)
params[param] = Config.get("BlobStore", param)
req = Request(env)
resp = Response(status=200, content_type="text/plain")
#engine = create_engine("mysql+mysqldb://%s:%[email protected]%s:%s/%s?charset=utf8&use_unicode=0" %
# (params["user"], secret.BlobSecret, params["host"], params["port"], params["database"]), pool_recycle=3600)
Base = declarative_base(bind=engine)
local.Session = []
local.FileEntry = []
Session.append(sessionmaker(bind=engine))
FileEntry.append(makeFileEntry(Base))
if req.path.startswith('/fx'):
if req.method == "GET":
resp.status_code, filename, resp.content_type, resp.response = self.__download(req)
if resp.content_type == "application/octet-stream":
resp.headers["Content-Disposition"] = "attachment; filename=%s" % filename
return resp(env, start_response)
elif req.method == "POST":
resp.content_type="text/plain"
resp.response = self.__upload(req)
return resp(env, start_response)
else:
resp.status_code = 404
resp.content_type="text/plain"
resp.response = ""
return resp(env, start_response)