Jump to content

Recommended Posts

Posted

I'm tryng to write my first Python script - so far all I can get it to do is produce an Internal Server Error (though my script runs OK at the command line on my local PC). Can someone just tell my how to do a Hello World Python script on TCH, just to get me started?

 

Thanks - Rowan

Posted

I just created and tested a guick one;

 

>#!/usr/bin/python

print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"

in a file hello.cgi, and set the permissions to 755 (so that you have execute permission), then just go to that file in your browser.

 

This only has the very basics - so of course hasn't got the full headers, and correct HTML ... but should get you started.

Posted

Andy - many thanks. I copied your exact code and still got Internal Server Error, but eventually pinned it down to file format - by default my editor uses MS-DOS (CR LF) line termination. When I changed it to LF only, it started working.

 

Now I can try to write some real code!

 

Thanks again - Rowan

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...