[Tutor] New Problems with script

Hugo González Monteverde hugonz-lists at h-lab.net
Fri Jul 22 03:24:28 CEST 2005


Hi,

First of all, try to include the relevan code *inline* instead of 
attaching. This creates all sort of problems, specially that it prevents 
the list archive from gracefully displaying your message.

You have this:

print "#blend {
     width: 10em;
     padding: 0;
     border: 1px solid black;
     margin-left: 3em
}


Double quoted strings cannot span more than one line, you should use 
triple-quotes instead.

In any case, you should try to run it outside the CGI environment to see 
what's wrong. In this case, you should have got a simple syntax error if 
run from the command line... if run from a CGI, it is more difficult to 
debug.

Hope it helps,

Hugo




gordnjen wrote:
> Hello all:
> 
> I am VERY new at any programming of any sort, so any help would be 
> appreciated.
> 
> This is the new and improved error message I get when I am trying to run 
> the attached script:
> 
> Script Error
> 
>  
> 
> There was an error with your script and it didn't exit properly.
> 
>  
> 
> This was its output:
> 
>  
> 
>   File "/home/jgates/public_html/Fifthone2.py", line 36
> 
>     print "#blend {
> 
>  
> 
> Any advice?
> 
>  
> 
> Jennine
> 
>  
> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.323 / Virus Database: 267.9.2/55 - Release Date: 21/07/2005
> 
> 
> ------------------------------------------------------------------------
> 
> import cgitb;
> cgitb.enable()
> import cgi
> form = cgi.FieldStorage()
> 
> print "Content-type: text/html"
> print
> print """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> 	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">"""
> 
> red1 = int (form["red1"].value)
> green1 = int (form["green1"].value)
> blue1 = int (form["blue1"].value)
> red2 = int (form["red2"].value)
> green2 = int (form["green2"].value)
> blue2 = int (form["blue2"].value)
> 
> nsteps = int (form["steps"].value)
> for i in range(nsteps):
>     print i,
> 
>     fraction = (i+1.0)/nsteps
>     r = (1-fraction)*red1 + fraction*red2
>     g = (1-fraction)*green1 + fraction*green2
>     b = (1-fraction)*blue1 + fraction*green2
> 
>     
> print "<html>"
> print "<head>"
> print "<title>Colour Blend</title>"
> print '<div class="colourblock"'
> print 'style="background-color: rgb(' + str(r) + '%,' + str(g) + '%,' + str(b) + '%)">'
> print '</div>'
> print "<style type= text/css>"
> print "#blend {
>     width: 10em;
>     padding: 0;
>     border: 1px solid black;
>     margin-left: 3em
> }
> ..colourblock {
>     width: 10em;
>     height: 1em;}"
> print "</style>"
> print "</head>"
> print "<body>"
> print "<h1>Colour Blend</h1>"
> print "<p>Here is a mix of the two colours you specified:</p>" print "<div id="blend">"
> print "</div>"
> print "<hr class= footlink >Return to <a href= </a>the index</a>.</p>"
> print "</body>"
> print "</html>"
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list