473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

I'm just not cut out for web programming, I guess :)

Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

I don't necessarily even want help just yet, I'd like to figure it out
myself, but can someone at least tell me why I'm not getting helpful
feedback from the cgitb module? Am I using it wrong? The webpage just
displays the internal server error.

Thanks.

import cryptogen
import cgitb; cgitb.enable()

quote_file = open('quotes.txt')
quote = quote_file.readline().strip()
quote_file.close()

print '''content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>

<body><form action="cryptopage.py">'''

quote = cryptogen.convert_quote(quote)
for word in quote[0].split(' '):
word_len = len(word)
print '<input type="text" name="%s" size="%d">' % (word, word_len)

print '<input type="submit" value="Submit"></form></body></html>'
May 17 '06 #1
6 1211
On Wed, 17 May 2006 20:51:07 +0000, John Salerno wrote:
Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

I don't necessarily even want help just yet, I'd like to figure it out
myself, but can someone at least tell me why I'm not getting helpful
feedback from the cgitb module? Am I using it wrong? The webpage just
displays the internal server error.

Thanks.


Having to debug web scripts on hosts where you don't have shell access can
be a major pain. If you are referring to the wrong path in the "bang-path"
line, you'd get that error non-message. Likewise if the file permissions
were wrong.

May 17 '06 #2
John Salerno wrote:
Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:

I don't necessarily even want help just yet, I'd like to figure it out
myself, but can someone at least tell me why I'm not getting helpful
feedback from the cgitb module? Am I using it wrong? The webpage just
displays the internal server error.

Thanks.

import cryptogen
import cgitb; cgitb.enable()

quote_file = open('quotes.txt')
quote = quote_file.readline().strip()
quote_file.close()

print '''content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en-us">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
</head>

<body><form action="cryptopage.py">'''

quote = cryptogen.convert_quote(quote)
for word in quote[0].split(' '):
word_len = len(word)
print '<input type="text" name="%s" size="%d">' % (word, word_len)

print '<input type="submit" value="Submit"></form></body></html>'


Are you sure the python that the web server runs has the cryptogen
module available? Have you set the execute bit on your script? What's
the output in your web server error log?

--
Paul McNett
http://paulmcnett.com
http://dabodev.com

May 17 '06 #3
Paul McNett wrote:
Are you sure the python that the web server runs has the cryptogen
module available?
Yes, this module and the cryptogen module (and the quotes.txt file) are
all in the same directory on the server.
Have you set the execute bit on your script?
Yes, I have them both set to 755.
What's
the output in your web server error log?


Well, I can't seem to find any error logs. In my logs folder, there are
files called 'access.log' and 'ftp.log', but nothing that looks like an
error log.
May 18 '06 #4
John Salerno wrote:
Paul McNett wrote:
Are you sure the python that the web server runs has the cryptogen
module available?


Yes, this module and the cryptogen module (and the quotes.txt file) are
all in the same directory on the server.
Have you set the execute bit on your script?


Yes, I have them both set to 755.
What's
the output in your web server error log?


Well, I can't seem to find any error logs. In my logs folder, there are
files called 'access.log' and 'ftp.log', but nothing that looks like an
error log.


Hmmm, looks like they don't do error logging:

Creating own error logs for debugging php scripts.

Since we dont provide access to Apache error logs on shared hosting
packages for
technical reasons, you can create your own error logs for debugging PHP
Scripts.

Please insert the following code in your PHP script (or create separate
file and
and add the code in it. Include the file using "include()")
error_reporting(0);
$old_error_handler = set_error_handler("userErrorHandler");

function userErrorHandler ($errno, $errmsg, $filename, $linenum,
$vars)
{
$time=date("d M Y H:i:s");
// Get the error type from the error number
$errortype = array (1 => "Error",
2 => "Warning",
4 => "Parsing Error",
8 => "Notice",
16 => "Core Error",
32 => "Core Warning",
64 => "Compile Error",
128 => "Compile Warning",
256 => "User Error",
512 => "User Warning",
1024 => "User Notice");
$errlevel=$errortype[$errno];

//Write error to log file (CSV format)
$errfile=fopen("errors.csv","a");
fputs($errfile,"\"$time\",\"$filename:
$linenum\",\"($errlevel) $errmsg\"\r\n");
fclose($errfile);

if($errno!=2 && $errno!=8) {
//Terminate script if fatal errror
die("A fatal error has occured. Script execution has been
aborted");
}
}

May 18 '06 #5
John Salerno wrote:
Ok, I've tinkered with this thing for a while, and I keep fixing little
problems, but I always get a 500 Internal Server error when I go to this
site:


Ok, in case anyone is curious, I figure out my problems. Let me first
give you a hint: my web server is running Python 2.2.1

On to the fun:

1. cgi traceback was not being displayed because the problem was with
the first import statement; i moved import cgitb above it and finally
got the nice-looking traceback info

2. i was importing itertools, which of course is not standard

3. i was using the built-in set(), which is new in 2.4

4. i tried to import sets, but that was new in 2.3

So the bottom line is I'm kind of screwed until I can get 1and1 to
update their Python! :) But at least I figured out some stuff.
May 18 '06 #6
John Salerno <jo******@NOSPAMgmail.com> writes:
So the bottom line is I'm kind of screwed until I can get 1and1 to
update their Python! :) But at least I figured out some stuff.


You should also look around for other hosting options. A web hosting
provider that doesn't give access to server logs isn't providing good
service.

--
\ "I'm beginning to think that life is just one long Yoko Ono |
`\ album; no rhyme or reason, just a lot of incoherent shrieks and |
_o__) then it's over." -- Ian Wolff |
Ben Finney

May 18 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Ben | last post by:
This is an exercise from the Non-programmers tutorial for Python by Josh Cogliati. The exercise is: Write a program that has a user guess your name, but they only get 3 chances to do so until...
99
by: Jim Hubbard | last post by:
It seems that Microsoft not only does not need the classic Visual Basic developer army (the largest army of developers the world has ever seen), but now they don't need ANY Windows developer at a...
13
by: Eric Pederson | last post by:
Raise your hand if you think the best technology wins! For those of you with your hands in the air, tell me: if Python is so good,why has PHP achieved such greater adoption and mindshare? Why...
9
by: tjones | last post by:
Hi, I am guessing this is *THE* nntp newsgroup for C#? I was hoping someone could point me in the right direction. Id like to find employment in the IT industry as a programmer again. My...
16
by: John Rivers | last post by:
http://www.15seconds.com/Issue/030812.htm?voteresult=1 poor guy worked his heart out, just to make a page control and then they published it ha ha ha ha ha to "help" others
18
by: Frankie | last post by:
I have been hired to go to a former client of mine and train their staff programmers on ASP.NET. These guys have only Mainframe, MS Access, SQL Server, and VB6 desktop application development...
4
by: Java Challenge | last post by:
I am trying to work hard to become a programmer and eventually get a job as a programmer, I have a low paying job at the moment as technical support and a family to maintain. 1 - I started to...
34
by: chandu | last post by:
Hello every body , upto now i saw advantages of C# only,i am curious about what are the disadvantages of C#..(because any programming language should have some positives and negatives..) Thanks...
21
by: shotokan99 | last post by:
guys, i read in some forums that php is just for hobbiest, and is not suited for some serius and heavy application. for robust and hi performance application asp.net or jsp is the way to go. how...
14
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
As far as I know, the C Standard has no mention of multi-threaded programming; it has no mention of how to achieve multi-threaded programming, nor does it mention whether the language or its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.