View previous topic :: View next topic |
Author |
Message |
TheHand -
Joined: 10 Nov 2003 Posts: 6
|
Posted: Wed Aug 18, 2004 10:15 pm Post subject: encoding issue in python? |
|
|
I have a webpage, which i want to make more dynamic with python.
Since my webeditor doesn't save in .py, i made a script to make html python. from <a>Hello</a> too print "<a>hello</a>", and so on.
fil = raw_input("What is my input file?")
file = open(fil)
fil2 = fil[:-5] + ".py"
file2 = open(fil2, "w")
file2.write("# -*- coding: cp1252 -*-\n")
while 1:
line = file.readline()
if not line:
break
line = '"""' + line.replace("\r\n", "") + '"""\r\n'
file2.write("print " + line )
file.close()
file2.close()
The program also adds what i think must be the correct encoding for norwegian, which is my language(sorry about the not perfect english).
And when i run the pythonfiles which comes out of this script, with the interpeter, the htmlcode flows nicely out. Everything seems to be right, no errors.
But when i head my browser towards this script, http://pinn.no-ip.biz/index.py , i get an 500 internal server error.
The cgi.log file reports no encoding decleared.
Any ideas, or shall i paste all the involved files (cgi.log, abyss.conf, the original html file, output python file)? |
|
Back to top |
|
|
Stone-D -
Joined: 09 Jan 2004 Posts: 90
|
Posted: Thu Aug 19, 2004 8:49 am Post subject: |
|
|
You seem to be forgetting the headers.
Essentially, a web page is :
Header1
Header2
Blank Line
Web Page
A basic example would be :
Code: |
Content-type: text/html
<html>
<head><title>Um, hello?</title></head>
<body>Blankety Blank!!</body>
</html>
|
The blank line is crucial in order to seperate header and body data.
So, to summarize, you need to add the header fields. At the moment, Abyss is thinking that your entire output is one massive header.
Btw, I'm less than clueless with python, I'm a perl n00b at the moment. =) _________________ --
Look, no SIG! |
|
Back to top |
|
|
TheHand -
Joined: 10 Nov 2003 Posts: 6
|
Posted: Thu Aug 19, 2004 9:37 am Post subject: Thanks |
|
|
It worked now :)
Really great.
Such a simple thing :(
Thanks for your help.
Abyss is a great webserver! |
|
Back to top |
|
|
senshi -
Joined: 05 Nov 2003 Posts: 385 Location: UK
|
Posted: Thu Aug 19, 2004 11:10 am Post subject: Re: Thanks |
|
|
TheHand wrote: | It worked now :)
Really great.
Such a simple thing :(
Thanks for your help.
Abyss is a great webserver! |
Which would be nice if you were to tell us all what the issue was instead of posting leaving us all clueless. |
|
Back to top |
|
|
Stone-D -
Joined: 09 Jan 2004 Posts: 90
|
Posted: Thu Aug 19, 2004 12:47 pm Post subject: Re: Thanks |
|
|
senshi wrote: | Which would be nice if you were to tell us all what the issue was instead of posting leaving us all clueless. |
Hehe, he did but at the bottom of his initial post. 500 Internal server error. _________________ --
Look, no SIG! |
|
Back to top |
|
|
|