简体   繁体   中英

Django How to Store HTML files in Amazon S3

I have a question regarding HTML files and Django. Can the django views file serve html files that are not stored locally and stored on amazon s3?

For example instead of:

def index(request):

    return render(request, 'index.html')

have something like:

def index(request):

    return render(request, 'http://bucket.s3.amazonaws.com/file.html')

Obviously its currently appending the url link to the folder it things html are served from.

Is this sort of thing even possible?

Thanks

I do not believe this is feasible. Web servers exists just for this reason: to serve HTML pages to clients . Amazon S3 exists for file storage, such as images, videos, js files, css files, fonts etc. Not HTML!

On the other hand, suppose this was feasible, your Web server should make a GET request to the HTML stored in S3 (to get the html), then fill it with context variables and then send it to the client ( response ).

The job of a Django view is to take a Web request and return a Web response . Not making another GET request to get the html which will send as a respose right away (!).

Hope that clarifies your question!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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