Overnight hack, trying to create an environment where GAE code (using Python libs/packages) could be easily ported over to Heroku with minimal editing.
EDIT<
On heroku platform, with high volume apps you're supposed to use amazon s3 for static asset storage: https://devcenter.heroku.com/articles/s3
For development purposes I created a simple "catch all" handler (it should be the last handler in the list) that serves static files that end with certain suffixes from the project directory. Adding this is quite simple. But remember, it's not very effective, and it's a waste of the web dynos resources.
import webapp2
import re
import os
class FileHandler(webapp2.RequestHandler):
def get(self,path):
if re.search('html$',path):
self.response.headers['Content-Type'] = 'text/html'
elif re.search('css$',path):
self.response.headers['Content-Type'] = 'text/css'
elif re.search('js$',path):
self.response.headers['Content-Type'] = 'application/javascript'
elif re.search('gif$',path):
self.response.headers['Content-Type'] = 'image/gif'
elif re.search('png$',path):
self.response.headers['Content-Type'] = 'image/png'
else:
self.abort(403)
try:
f=open("./"+path,'r')
except IOError:
self.abort(404)
self.response.write(f.read())
f.close
app = webapp2.WSGIApplication([
(r'/(.*)', FileHandler),
], debug=True)
def main():
from paste import httpserver
port = int(os.environ.get('PORT', 8080))
httpserver.serve(app, host='0.0.0.0', port=port)
if __name__ == '__main__':
main()