molotov00
June 13th, 2008, 05:41 AM
Hey Guys,
I have a basic python script that just displays some html pulled from a database.
See the page here:
http://jubuntu.dyndns.org/read.py
You see... I have html tags but the browser displays it instead of parsing it. I see:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> in my browser.
I don't think it's Apache because regular html and even php pages render correctly. I think it's mod_python.
My script:
from mod_python import apache
#def index(req):
def index(req):
req.content_type = 'text/plain'
import sqlite3
conn = sqlite3.connect("/var/www/articles.db")
c = conn.cursor()
op = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
<title>iShares: Premium/Discount Chart</title>"""
c.execute('select title,id from articles where site="wsj" order by time')
op += "WSJ Articles<br />"
for row in c:
op += row[1] + " " + row[0] + "<br />"
req.write(op)
return apache.OK
If I use "return op" instead of req.write and ommit req.content_type the results are the same.
Any ideas?
I have a basic python script that just displays some html pulled from a database.
See the page here:
http://jubuntu.dyndns.org/read.py
You see... I have html tags but the browser displays it instead of parsing it. I see:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> in my browser.
I don't think it's Apache because regular html and even php pages render correctly. I think it's mod_python.
My script:
from mod_python import apache
#def index(req):
def index(req):
req.content_type = 'text/plain'
import sqlite3
conn = sqlite3.connect("/var/www/articles.db")
c = conn.cursor()
op = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" py:replace="''"/>
<title>iShares: Premium/Discount Chart</title>"""
c.execute('select title,id from articles where site="wsj" order by time')
op += "WSJ Articles<br />"
for row in c:
op += row[1] + " " + row[0] + "<br />"
req.write(op)
return apache.OK
If I use "return op" instead of req.write and ommit req.content_type the results are the same.
Any ideas?