share
Stack OverflowError in Displaying the content of a txt file through Django
[-4] [1] Soumya Ranjan Sahu
[2019-12-27 18:30:58]
[ python django ]
[ https://stackoverflow.com/questions/59504717/error-in-displaying-the-content-of-a-txt-file-through-django ]

[This is the text file I want to project in the browser screen.

The second one is the views file which has the function. path('ShowFile', views.ShowFile, name ='ShowFile') in the last picture in the urls.py [1]

[0] [2019-12-27 18:37:03] Soumya Ranjan Sahu

You may use a function like this, substituting the path as needed.

def ShowFile(request):
    f = open("C:\\Users\\Soumyaranjan\\PycharmProjects\\Textutils\\textutils\\textutils\\one.txt", "r")
    content = f.readlines()
    return HttpResponse(content)

1