Current time: 04-23-2014, 12:59 AM Hello There, Guest! (LoginRegister)

Post Reply 
Display source code as text
03-06-2012, 03:18 PM
Post: #1
Display source code as text
Hi everyone,

I'm pretty new to web development, and I've run into an issue that I don't really know enough terminology about to look in the right places.

I have a file foo.py that I have on my site, and when someone accesses that file on the web, I want to make it so that it displays the source code of the file as it would a .txt file. However, when I try to navigate to this page, I instead get a 500 Internal Server Error.

Upon checking my server log, I see the following error:

[error] [client XXX.XXX.XXX.XXX] Premature end of script headers: foo.py

Does anyone know how to fix this? Even just letting me know what to search for would be appreciated.
Find all posts by this user
Quote this message in a reply
03-06-2012, 03:32 PM
Post: #2
RE: Display source code as text
Rename or copy the file to .txt extension.

for php, i have a line of code that can be included in the file so that you can add a URL extension of "?sce=view" to the end of the URL to make it viewable. Don't know if there is an equivent for python tho.
Find all posts by this user
Quote this message in a reply
03-06-2012, 03:57 PM
Post: #3
RE: Display source code as text
Code:
RemoveHandler .py

Add that directive to a .htaccess file in your source directory.

Result : http://sxi.sabrextreme.com/python

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost
Visit this user's website Find all posts by this user
Quote this message in a reply
03-07-2012, 10:23 PM
Post: #4
RE: Display source code as text
Fantastic! It works now. Thanks!
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: