www.webdeveloper.com
Results 1 to 2 of 2

Thread: How can I Combine Python & HTML together?

  1. #1
    Join Date
    Sep 2005
    Posts
    1

    Exclamation How can I Combine Python & HTML together?

    Hello, for a website I'm building now, I need to work with both Python, and HTML. The database is Python, and the grafic interface is going to be in HTML. That's the assignment. I've tried to use the GET tool in HTML, but so far it won't work. This is just a try what I'm doing right now, but I've got excactly NO F*CKING CLUE what to do. THe HTML I use to get this form:

    form method="action" action="cgi2shl.py"

    In python stands this file:

    #!/Programme/Python/python
    "Script: Trewatment of parameters with GET, Standard CGI"
    # -*- coding: ISO-8859-1 -*-

    import time,os,sys,traceback
    import string,regex

    def zeit():
    cc=time.time()
    cd=time.asctime(time.localtime(cc))
    ce=cd[:11]+cd[20:]
    tt=cd[11:19]
    return ce,tt

    try:
    heute,lt=zeit()
    user=os.environ["http_user_agent"]
    ort=os.environ["REMOTE_ADDR"]
    para=os.environ["QUERY_STRING"]

    para_l=string.split(para,"&")
    ll=len(para_1)
    para_d={}
    pattern="[a-z]+"
    for i in range(11):
    data=para_l[i]
    j=regex.match(pattern,data)
    key=data[:j]
    value=data[j+1:]
    if not para_d.has_key(key):
    para_d[key]=[value]
    else:
    para_d[key]=para_d[key]+[value]

    user=string.join(para_d["name"])
    user=string.replace(user,"+"," ")
    email=string.join(para_d["E-Mail"])
    if para_d.has_key("service"):
    www=string.join(para_d["service"])
    www=string.replace(www," ",", ")
    else:
    www="world Wide Web"

    print "content/type: text/html "
    print " "
    print "<html><head><title>Test</title></head>"
    print "<body><h1>testpage</h1>"
    print "Welcome: "+user+" from "+ ort + "<br><hr>"
    print "Today: <b>"+heute+"</b><br>"
    print "Servertime: <b>"+lt+"</b><br>"
    print "<p> <b>More information:</b><br>Your e-mail: "+E-Mail+" "
    print "<br> Used from internet: "+ www + " </p>"
    print "</body></html>"

    except:
    print 'Content-Type: text/plain\n'
    traceback.print_exc(file=sys.stdout)


    is there anyone on this freaking planet who can help me during my search for this database interface? Thank you if you can. I really appreciate it.


  2. #2
    Join Date
    Feb 2005
    Posts
    75
    I think you have a server-side issue.
    Consider closing all your HTML tags though, this will aid accessibility in the future. This should help you:
    http://www.w3schools.com/xhtml/xhtml_why.asp

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles