简体   繁体   English

Flask render_template S3中的HTML

[英]Flask render_template where HTML is in S3

Can I have templates stored in S3 send to render_template ? 我可以将存储在S3中的模板发送到render_template吗?

application_root = config.get_application_root()
static_folder = os.path.join(application_root, 'static')
template_folder = os.path.join(application_root, 'templates')
app = Flask(__name__, static_url_path='/static', static_folder=static_folder, template_folder=template_folder)

Easy solution would be to download s3 objects to a server directory and point render_template to pick from that directory. 一种简单的解决方案是将s3对象下载到服务器目录,然后指向render_template从该目录中进行选择。

I am wondering if this intermediate step is ever required. 我想知道是否需要这个中间步骤。 I have web_content passed down as pre-built HTML files and do not generate them. 我已经将web_content传递为预构建的HTML文件,并且不生成它们。 Can I send HTML as a string to render_template without actually having a HTML file? 是否可以在没有实际HTML文件的情况下将HTML作为字符串发送到render_template?

/flask_folder 
----/app.py
----/templates/
----/static/

/my_external_template_folder

Use render_template_string instead of render_template : 使用render_template_string代替render_template

http://flask.pocoo.org/docs/1.0/api/#flask.render_template_string http://flask.pocoo.org/docs/1.0/api/#flask.render_template_string

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

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