当前位置: 首页>>代码示例>>Python>>正文


Python Response.content_disposition方法代码示例

本文整理汇总了Python中werkzeug.Response.content_disposition方法的典型用法代码示例。如果您正苦于以下问题:Python Response.content_disposition方法的具体用法?Python Response.content_disposition怎么用?Python Response.content_disposition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.Response的用法示例。


在下文中一共展示了Response.content_disposition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from werkzeug import Response [as 别名]
# 或者: from werkzeug.Response import content_disposition [as 别名]
 def __call__(self, env, start_response):
     req = Request(env)
     Config = ConfigParser()
     Config.read(configfile)
     params = {"host": "", "user": "", "database": "", "port": ""}
     for param in params:
         if not Config.has_option("MySQL", param):
             print "Malformed configuration file: mission option %s in section MySQL" % (param)
             sys.exit(1)
         params[param] = Config.get("MySQL", param)
     #print params
     #engine = create_engine("mysql+mysqldb://%s:%[email protected]%s:%s/%s?charset=utf8&use_unicode=0" %
     #    (params["user"], secret.MySQL, params["host"], params["port"], params["database"]), pool_recycle=3600)
     Base = declarative_base(bind=engine)
     local.Session = []
     local.Package = []
     local.Session.append(sessionmaker(bind=engine))
     local.Package.append(makePackage(Base))
     resp = Response(status=200, content_type="text/plain")
     if req.path == '/pkg/upload':
         resp.content_type="text/html"
         resp.response = self.__upload(req)
         return resp(env, start_response)
     elif req.path == '/pkg/sdk':
         resp.content_disposition="application/force-download"
         resp.content_type="application/python"
         resp.headers.add("Content-Disposition", "attachment; filename=appcfg.py")
         f = open("appcfg.py").read().replace("__REPO_UPLOAD__", '"%s"' % (req.host_url + 'pkg/upload'))
         resp.headers.add("Content-Length", str(len(f)))
         resp.response = [f]
         return resp(env, start_response)
     elif req.path.startswith('/pkg'):
         resp.status_code, resp.content_encoding, resp.response = self.__download(req)
         return resp(env, start_response)
     else:
         resp.status_code = 404
         resp.response = [""]
         return resp(env, start_response)
开发者ID:dpq,项目名称:spooce,代码行数:40,代码来源:repo.py


注:本文中的werkzeug.Response.content_disposition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。