Answer the question
In order to leave comments, you need to log in
How to redirect request to local html in django?
Hello.
I am writing a project based on the django framework and faced such a task, on the server where the django application is running, there is a folder in which a third-party program adds the results of its work in the form of html files and various statics for this html. Tell me how it is possible in django to read this file with all the necessary statics and return this html to the user. Now I do this:
views.py
...
def result(request, _id):
log_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "Results", 'log.html')
log = open(log_path)
html = log.read()
log.close()
return HttpResponse(html)
...
Answer the question
In order to leave comments, you need to log in
Django has nothing to do with it, just set nginx/apache on this folder and that's it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question