简体   繁体   English

在heroku上提供带烧瓶的静态html页面

[英]Serving static html pages with flask on heroku

Im trying to figure out how to serve static pages from heroku with a flask app. 我试图弄清楚如何使用烧瓶应用程序从heroku提供静态页面。 I found this with some searching: 我找到了一些搜索:

@app.route('/foo/<path:filename>')
def send_foo(filename):
     return send_from_directory('/path/to/static/files', filename)

But, this would be quite inefficient. 但是,这将是非常低效的。 Is there a way to have the front facing server directly serve these files? 有没有办法让前置服务器直接提供这些文件?

Normally you would do this with mod_rewrite with apache or similar, but afaik heroku doesn't let's you change the http server configuration. 通常你会使用带有apache或类似的mod_rewrite来执行此操作,但afaik heroku不允许你更改http服务器配置。

You'll need to use the rack middleware, it lets you write url rewrite rules with ruby. 您需要使用机架中间件,它允许您使用ruby编写URL重写规则。 (check this out : http://icelab.com.au/articles/useful-heroku-friendly-rewrites-with-rack-rewrite/ ) (看看这个: http//icelab.com.au/articles/useful-heroku-friendly-rewrites-with-rack-rewrite/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM