N
N
Nikolai Pavlov2016-05-24 05:41:10
Django
Nikolai Pavlov, 2016-05-24 05:41:10

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)
...

But in this case, all the pictures that are next to log.html are not available. Maybe there is an opportunity in django to simply give a link to the local location of log.html or somehow pack this log.html so that all the statics are inside?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oscar Django, 2016-05-24
@winordie

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 question

Ask a Question

731 491 924 answers to any question