Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- print("Content-type: text/html\n")
- import cgi
- import MySQLdb
- string = "i211f18_affoster"
- password = "my+sql=i211f18_affoster"
- db_con = MySQLdb.connect(host = "db.soic.indiana.edu", port = 3306, user = string, passwd = password, db = string)
- cursor = db_con.cursor()
- printing = """<!doctype html>
- <html>
- <head>
- <title>Robot Delivery System</title>
- </head>
- <body>
- <h1>What would you like to have delivered</h1>
- <form action = "addDelivery.cgi" method = "post">"""
- try:
- sql = "select items.itemName from items;"
- cursor.execute(sql)
- result = cursor.fetchall()
- except Exception as e:
- print("something wrong")
- else:
- for row in result:
- printing += """<input type = "radio" name = "item" value = '""" + row[0] + "'>" + row[0] + "<br>\n"
- printing += """<h2>Cost: $</h2>
- <br>
- <input type = "text" name = "cost">
- <br>
- <h2>Delivery Method:</h2>
- <br>
- <input type = "radio" name = "method" value = "drone">Flying Drone ($10)
- <br>
- <input type = "radio" name = "method" value = "car">Self Driving Car ($20)
- <br>
- <input type = "radio" name = "method" value = "robot">Giant Robot ($1000)
- <br>
- <button type = "submit">Submit</button>
- </form>
- </body>
- </html>"""
- print(printing)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement