How to view a linux file?

Is there a way to use Python's http server modules to enable me to view a log file residing on a Linux box?

  • I tried the python -m SimpleHTTPServer way, but it asks me to save the log file. What I want is that the browser should display the file content, rather than asking me to save it. (Here, the directory may be pre-defined, but the log file names keep changing) In other words, I want to tell my app developers : Hey guys, here is the URL which lists the log files. Click on your log file, and you will see what is going on in real time. Any ideas? Thanks a bunch

  • Answer:

    A simple `python -m http.server` should suffice. My guesstimate is that the log files you are trying to serve have a non-standard extension, with respect to webpages. This includes files with a .log extension. If you want your users to be able to directly view the files in their browsers, simply rename the log files to have a .txt extension. Browsers seem to have a white list of file extensions which are displayed in the browser, all others are considered binary objects and downloaded.

Darshit Shah at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.