简体   繁体   English

在heroku上提供静态文件

[英]Serving static files on heroku

I'm writing a Python app for heroku. 我正在为heroku编写一个Python应用程序。 Flask is used for the web component of the app. Flask用于应用程序的Web组件。

My problem is that I can't find a way to serve static files. 我的问题是我找不到提供静态文件的方法。 I don't want to do it through flask because that is very inefficient. 我不想通过烧瓶来做,因为这是非常低效的。

I'm also using gunicorn. 我也在使用gunicorn。 How would I set up serving of static files? 我如何设置静态文件的服务?

Try using Amazon s3 for storing static and media files. 尝试使用Amazon s3存储静态和媒体文件。 A similar question and answer can be found here . 这里可以找到类似的问题和答案。 Here is heroku's documentation of using s3. 是heroku使用s3的文档。 Then you might want to disable automatic collectstatic instructions here so collectstatic isn't run every time you push to heroku. 然后你可能想要在这里禁用自动collectstatic 指令,所以每次你推送到heroku时都不会运行collectstatic。 Hope this helps. 希望这可以帮助。

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

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