vendredi 25 mars 2016

Creating a web application

I'm creating a webapp in python, where I have a list of quotes and pictures. One of each will be randomly generated within the app:

import random

if __name__=="__main__":

    print("Content-type: text/html")
    print()

    quotes=["The course of true love never did run smooth.", "Life every man holds dear; but the dear man holds honor far more precious dear than life.",
"To thine own self be true, and it must follow, as the night the day, thou canst not then be false to any man.", "Poor and content is rich, and rich enough.",
"If you have tears, prepare to shed them now.", "Words without thoughts never to heaven go."]


    pics=["http://ift.tt/22LIsHt", "http://ift.tt/25oX2Xt",
      "http://ift.tt/22LIsah", "http://ift.tt/25oX55x",
      "http://ift.tt/22LIsXI", "http://ift.tt/1hf2gvt"]




    print """
<html>
<head>
<title>QOTD: Shakespeare </title>
</head>

<body>
<center> 
<img src="%s">
<p>
<font size="12"><b>The quote of the day is:</b></font>
<p>
<table>
    <tr>
    <td width="500"><font size="6">%s</font>
    </td>
    </tr>
</table>
</p>
</center>
</body>
</html>
""" % (random.choice(quotes), random.choice(pics))

I keep getting a syntax error, and can't seem to figure out what is wrong. Please be simple, I'm pretty new to Python! Thank you in advance.




Aucun commentaire:

Enregistrer un commentaire