【发布时间】:2012-01-18 05:39:06
【问题描述】:
我现在正在将我的小型 Google App Engine 应用程序迁移到 Heroku 平台。我实际上并没有使用 Bigtable,webapp2 大大降低了我的迁移成本。
现在我被困在处理静态文件上。
有什么好的做法吗?如果有,请带我去。
提前致谢。
编辑
好吧,我现在将paste 用于我的 WSGI 服务器。 paste.StaticURLParser() 应该是我实现静态文件处理程序所需要的。但是我不知道如何将它与webapp2.WSGIApplication() 集成。谁能帮帮我?
也许我需要重写 webapp2.RequestHandler 类才能正确加载 paste.StaticURLParser();
import os
import webapp2
from paste import httpserver
class StaticFileHandler(webapp2.RequestHandler):
u"""Static file handler"""
def __init__(self):
# I guess I need to override something here to load
# `paste.StaticURLParser()` properly.
pass
app = webapp2.WSGIApplication([(r'/static', StaticFileHandler)], debug=True)
def main():
port = int(os.environ.get('PORT', 5000))
httpserver.serve(app, host='0.0.0.0', port=port)
if __name__ == '__main__':
main()
任何帮助将不胜感激!
【问题讨论】:
标签: python heroku static-files webapp2