import sqlite3,cgi print("Content-Type:text/html\r\n\r\n") conn=sqlite3.connect("gitam.db") cur=conn.cursor() form=cgi.fieldStorage() ename=form.getvalue("ename") query="select * from emp where ename="+ename try: rs=cur.execute(query) except Exception as e: print(e) else: for record in cur: pass html='''<html> <body> <form action="update.py"method="put"> eno:<input type="text" value="%s"name="eno"> ename:<input type="text" value="%s" name="ename"> edept:<input type="text" value="%s" name="edept"> <input type="submit" value="update"> </from> </body> </html>'''%(str(record[1], record[2])) print(html) finally: cur close() conn close()
import cgi data = cgi.fieldStorage() textstring = data.getvalue('textString') numberentry = data.getvalue('numberEntry') def add10(x): y = x + 10 return y print('Content=type:text/html \r\n\r\n') print('Hello World') print('<!DOCTYPE HTML>') print('<html>') print('<head>') print('<title>The Python response</title></head>') print('<body>') print('<p>You entered: ', textstring, '</p>') print('<p>This is the number you entered:</p>') print('<p>', numberentry, '</p>') print('<p>This is the number with the function applied:</p>') print('<p>', add10(int(numberentry)), '</p>') print('</body></html>')
from datetime import datetime html_body = u""" <!DOCTYPE html> <html lang="ja"> <head> <meta http-equiv="content-type" content="text/html;charset="UTF-8"> <title></title> </head> <body> %s </body> </html> """ content='' form=cgi.fieldStorage() year_str=form.getvalue('year', '') if not year_str.isdigit() : content=u"西暦を入力してください" else: year=int(year_str) friday13==0 for omonth in range(1, 13): date=datetime(year, month, 13) if date.weekday()==4: friday13+=1 content+=u"%d年%d月13日は金曜日です" % (year, date.month) content+=u"<br />" if friday13:
#!/usr/bin/python # -*- coding: iso-8859-1 -*- import cgi, cgitb, os, json, sys cgitb.enable() # see peaks siis kusagil üpris algul olema print "Content-type: text/html" # mõistlik panna kohe programmi algusse print fieldStorage = cgi.fieldStorage() scorefile = "/prax3/score.txt" inmethod = os.environ["REQUEST_METHOD"] if inmethod == "POST": indata = sys.stdin.read() data = json.loads(indata) print data
#!/usr/bin/env python import os import cgi import cgitb import sqlite3 cgitb.enable() data = cgi.fieldStorage() artist = data["artist"] album = data["album"] db = sqlite3.connect("muscrape.db") cur = db.cursor albumData = cur.execute("select * from albums where artist=? and album=?", artist, album) print "Content-Type: text/html" print print """<!doctype html> <html> <head> <meta charset="UTF-8"> <link rel="stylesheet" type="text/css" href="/static/style.css"> <title>%s - %s</title> <head> <body> yeah </body> </html> """ % artist + ' - ' + album
import cgi import cgitb cgitb.enable(); formData=cgi.fieldStorage(); print("Content-type: text/html\n\n") print(formData.getValue('searchbox'));