def main(): # Arguments: form = cgi.FieldStorage() if form.getvalue('unique_id'): uid = cgi.escape(form.getvalue('unique_id')) card_id = cgi.escape(form.getvalue('card_id')) db = settings.get_db() # Print basic HTML stuff: base.begin() base.header(title='Adding a unique ID...') base.header_redirect("module.py?db={0}&card_id={1}".format(db, card_id)) base.top(db) # Add: try: con = connect(True, db) cur = con.cursor() cur.execute('UPDATE Card SET unique_id="{0}" WHERE card_id={1}'.format(uid, card_id)) con.commit() con.close() except Exception as err: print "<span style='color: red'>ERROR</span><br>" print err # print("<h3>Serial number already exists!</h3>") base.bottom()
def homePage(data): print(""" <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <title>Hello, world!</title> <link rel="stylesheet" href="styles.css"> </head> <body> """) base.header(data[0][1]) print("<div class='container'>") print("<h3>Welcome {}</h3>".format(data[0][0])) print("</div>") print(""" </body> </html> """)
def main(): # Arguments: form = cgi.FieldStorage() sn = form.getvalue("serial_number") db = settings.get_db() if sn: try: con = connect(True, db) cur = con.cursor() cur.execute("INSERT INTO Card SET sn = '{0}'; ".format(sn)) con.commit() con.close() except Exception as ex: base.begin() base.header(title='{0}: add module'.format(db)) base.top(db) print ex print '<center><h3 style="color:red"><i>Serial number "{0}" already exists! It was not added.</i></h3></center>'.format(sn) else: cardid = module.fetch_cardid_from_sn(db,sn) base.begin() base.header_redirect("module.py?db={0}&card_id={1}".format(db,cardid)) base.top(db) else: base.begin() base.header_redirect("home.py?db={0}".format(db),1) base.top(db) print '<center><h3 style="color:red"><i>Tried to input null serial number. Do not do that.</i></h3></center>'.format(sn) base.bottom()
def main(): # Identify DB from URL: db = settings.get_db() base.begin() # Print the preamble and opening html tag. base.header(title='ePorridge') # Print the header. base.top(db) # Print the top portion of the body (title, buttons). This remains the same for every page. print_home(db) # Print what should appear on the home page. (Defined above.) base.bottom() # Print footer (if applicable) and closing body and html tags.
def main(): # Arguments: form = cgi.FieldStorage() cardid = base.cleanCGInumber(form.getvalue('card_id')) db = settings.get_db() # Basic: base.begin() base.header(title='{0}: module'.format(db)) base.top(db) # Form: print_form(db, cardid) base.bottom()
def main(): db = settings.get_db() base.begin() base.header(title='{0}: tests'.format(db)) base.top(db) print_test_info_table(db) print '<br><br>' print_testtype_form(db) print_card_info_table(db) print '<br><br>' print_cardinfotype_form(db) base.bottom()
def main(): # Arguments: db = settings.get_db() # Basic: base.begin() base.header(title='{0}: summary'.format(db)) base.top(db) # Modules table: print_stat_table(db) print_tests_table(db) print_modules_table(db) # End: base.bottom()
def main(): # Arguments form = cgi.FieldStorage() cardid = base.cleanCGInumber(form.getvalue('card_id')) suggested_test = base.cleanCGInumber(form.getvalue('suggested')) db = settings.get_db() sn = module.fetch_sn_from_cardid(db, cardid) # Basic: base.begin() base.header(title='{0}: test'.format(db)) base.top(db) # Test form: print_test_form(db, cardid, sn, suggested_test) base.bottom()
def homePage(result): if isinstance(result, str): base.plainHeader() print(f''' <h1>{result}</h1> ''') elif isinstance(result, User): base.header(result.email) print(f''' <h1>Welcome {result.name}</h1> ''') else: base.header(result[1]) print(f''' <h1>Welcome {result[0]}</h1> ''') base.footer()
def main(): db = settings.get_db() base.begin() base.header(title='{0}: testers'.format(db)) base.top(db) print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width:650px" align="center">' print '<tr>' print '<th > Name </th>' print '<th > ID </th>' print '</tr>' userInfo = fetch_user_info(db) for user in userInfo: print '<tr>' print u'<td align="left">{0}</td>'.format(user['name']).encode("utf-8") print '<td align="left">',user['id'],'</td>' print '</tr>' print '</table>' print '</div>' print '</div>' print '<br><br>' print '<form action="add_tester.py?db={0}" method="post" enctype="multipart/form-data">'.format(db) print '\t<div class="col-md-6">' print '\t\t<b>Add tester</b><br>' print '\t\ttester name:<br>' print '\t\t<textarea name="testerName" cols="35" rows="1"></textarea><br>' print '\t\t<input type="submit" value="Submit">' print '\t</div>' print '</form>' base.bottom()
import cgi import base import home_page_list import cgitb cgitb.enable() #cgi header print "Content-type: text/html" print print "<html><head>" print "" print "</head><body>" base.header(title='ePortage Home Page') base.top() print '<div class="row">' print '<div class="col-md-3">' print '<h2>List of All Boards</h2>' print '<b><em>(Sorted by Serial Number)</em></b>' print '</div>' print '<div class="col-md-3">' print '<br><br>' print '<a href="add_module.py">' print '<button type="button">Add a New Board</button>' print '</a>' print '</div>' print '</div>'
#!/usr/bin/python import cgi import base import home_page_list import module_functions from connect import connect #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() card_id = base.cleanCGInumber(form.getvalue('card_id')) serial_num = base.cleanCGInumber(form.getvalue('serial_num')) base.header(title='QIE card ePortage') base.top() #print 'card_id = ', card_id #print 'serial_num = ', serial_num module_functions.add_test_tab(serial_num, card_id) revokes = module_functions.Portage_fetch_revokes(serial_num) db = connect(0) cur = db.cursor() cur.execute( "select test_type, name from Test_Type where required = 1 order by relative_order ASC" ) for test_type in cur: module_functions.ePortageTest(test_type[0], serial_num, test_type[1], revokes)
import cgi, base, DB fieldStorage = cgi.FieldStorage() query = fieldStorage.getvalue('q').lower() intents = { "mobiles" : ['mobiles', 'mobile', 'phone', 'smartphone'], "televisions" : ['tv', 'smart tv', 'android tv', 'led tv', 'oled tv'], "refrigerators" : ['fridge', 'single door fridge', 'double door fridge'], "washing-machines" : ['washing machines', 'washing', 'automatic washing', 'washing machine'], "home-kitchen" : ['kitchen', 'home products', 'kitchen products', 'home kitchen'], 'watches' : ['watch', 'smartwatch', 'wrist watch', 'clock'], "men's fashion" : ['men fashion', 'mens', 'mens fashion', "man", "men"], "women's fashion" : ['women fashion', "fashion", 'women', "womens", "womens fashion", "woman"] } for category in intents: if query in intents[category]: query = category break # products = base.getProducts() base.header("Products") for product in DB.products: if query in product['product_sub_category'] or query in product['product_brand'].lower() or query in product['product_name'].lower() or query == product['product_category']: base.createProduct(product) base.footer()
#!/usr/bin/python import cgi import base import home_page_list # Print basic HTML stuff: base.begin() base.header(title='Adding a unique ID...') base.top() form = cgi.FieldStorage() if form.getvalue('unique_id'): qid = cgi.escape(form.getvalue('unique_id')) card_id = cgi.escape(form.getvalue('card_id')) serial_num = cgi.escape(form.getvalue('serial_num')) home_page_list.add_id(serial_num, qid) # print card_id, serial_num, qid base.bottom()
#!/usr/bin/python import cgi import base import home_page_list #import add_test_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() test_id = base.cleanCGInumber(form.getvalue('test_id')) #suggested_test = base.cleanCGInumber(form.getvalue('suggested')) base.header(title='Revoke Success') base.top() print '<br><br>' print 'Revoking test %i from list of valid tests'%test_id print 'Please add any comments about why the test is being revoked:' print '<form action="revokeFormHandler.py" method="post" enctype="multipart/form-data">' print ' <input type="hidden" name="test_id" value=%i>'%test_id print ' <br><br>' print ' <textarea rows="5" cols="100" name="comments"></textarea>' print ' <br><br>' print ' <input type="submit" value="Revoke">' print '</form>' base.bottom()
#!/usr/bin/python import cgi import base import home_page_list import add_test_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() #card_id = form.getvalue('card_id') serial_num = base.cleanCGInumber(form.getvalue('serial_num')) suggested_test = base.cleanCGInumber(form.getvalue('suggested')) person_id = base.cleanCGInumber(form.getvalue('person_id')) base.header(title='Add Test Results') base.top() add_test_functions.add_test_template(serial_num,suggested_test,person_id) base.bottom()
#!/usr/bin/python import cgi import cgitb ; cgitb.enable() from connect import connect import mysql.connector import base #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() infoName = form.getvalue("infoName","no name found") descShort = form.getvalue("descShort","no description found") descLong = form.getvalue("descLong","no description found") base.header(title='Add Card Info Type') base.top() db = connect(1) cur = db.cursor() cur.execute("INSERT INTO Card_Info_Types (Info_Name,Info_Desc_Short,Info_Desc_Long) VALUES ('{0}','{1}','{2}');".format(infoName,descShort,descLong)) db.commit() db.close() base.bottom()
# IMPORTS: import cgi import base import home_page_list import cgitb cgitb.enable() # /IMPORTS # FUNCTIONS: def print_home(): print'''\t\t<div class="row"> <div class="col-md-3"> <h2>All Boards:</h2> <strong><em>(Sorted by serial number)</em></strong> </div> <div class="col-md-3"> <br><br> <a href="add_module.py"><button type="button">Add a new board</button></a> </div> </div> <br><br>''' home_page_list.render_list_module() # /FUNCTIONS #cgi header base.begin() # Print the preamble and opening html tag. base.header(title='Acceptance Test Database') # Print the header. base.top() # Print the top portion of the body (title, buttons). This remains the same for every page. print_home() # Print what should appear on the home page. (Defined above.) base.bottom() # Print footer (if applicable) and closing body and html tags.
#!/usr/bin/python import cgi import base import home_page_list #cgi header print "Content-type: text/html\n" base.header(title='Add a new module to ePortage') base.top() home_page_list.add_module_form() print '<div class="row">' print '<div class="col-md-3">' print '<h2>List of All Boards</h2>' print '<b><em>(Sorted by Serial Number)</em></b>' print '</div>' print '</div>' print '<br><br>' home_page_list.render_list_module() base.bottom()
#!/usr/bin/python import cgi import cgitb cgitb.enable() import base from connect import connect import mysql.connector from testSetup_functions import get import module_functions #cgi header print "Content-type: text/html\n" base.header(title='Setup') base.top() print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width:100%">' print '<tbody>' print '<tr>' print '<th> Name </th>' print '<th> Description </th>' print '<th> Required? </th>' print '</tr>' testInfo = get() for test in testInfo: print '<tr align=left>' print '<td>', test['name'], '</td>'
#!/usr/bin/python import cgi import base from connect import connect import mysql.connector from testers_functions import get import module_functions #cgi header print "Content-type: text/html\n" base.header(title='Summary') base.top() print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width:650px" align="center">' print '<tr>' print '<th > Name </th>' print '<th > ID </th>' print '</tr>' userInfo = get() for user in userInfo: print '<tr>' print '<td align="left">', user['name'], '</td>' print '<td align="left">', user['id'], '</td>' print '</tr>' print '</table>'
#!/usr/bin/python import cgi import base from connect import connect import mysql.connector from summary_functions import get, id_from_name import module_functions #cgi header base.begin() base.header(title='ATD: F/W Versions') base.top() List_of_rows = get() for li in List_of_rows[4]: print '///', li print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width: 100%; font-size: 12px">' print '<tbody>' print '<tr>' print "<th style='background-color: #F0F0F0; font-size: 16px;'> S/N </th>" print "<th colspan=2 style='background-color: #F0F0F0; text-align: center; font-size: 16px;'> Tests Remaining </th>" print '<th colspan=2 style="background-color: #D7FFCA; text-align: center; font-size: 16px;"> Tests Passed </th>' print '<th colspan=2 style="background-color: #FFD4D4; text-align: center; font-size: 16px;"> Tests Failed </th>' #print '<th> Final Status </th>' print '</tr>'
#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 import base, cgi, product_base, DB fieldStorage = cgi.FieldStorage() pid = int(fieldStorage.getvalue('pid')) # products = base.getProducts() base.header( "<img src='https://rukminim1.flixcart.com/flap/844/140/image/0e5483e33a969756.jpg?q=50'>" ) for product in DB.products: if pid == product['product_id']: product_base.createHorizontalProduct(product) base.footer()
} #dash h2 { text-align: center; font-family: 'Dancing Script', cursive; font-size: 67px; font-weight: bold; } #dash h5 { font-family: 'Dancing Script', cursive; font-weight: bold; } </style> </head> <body>""") base.header() print(""" <h2 class="text-center">Start Test</h1> <hr> """) if len(test) == 0: print("<h2>No Test Available for this subject</h2>") else: print(""" <h2 class="text-center">Test Available Here </h2> <table width='100%' border=2 cellpadding=10> <tr> <th>Test ID</th> <th>Subject</th> <th>Grade</th> <th>Start Test</th>
#!/usr/bin/python import cgi import base import home_page_list import cgitb cgitb.enable() #cgi header print "Content-type: text/html" print print "<html><head>" print "" print "</head><body>" base.header(title='ePortage Home Page') base.top() print '<div class="row">' print '<div class="col-md-3">' print '<h2>List of All Boards</h2>' print '<b><em>(Sorted by Serial Number)</em></b>' print '</div>' print '<div class="col-md-3">' print '<br><br>' print '<a href="add_module.py">' print '<button type="button">Add a New Board</button>' print '</a>' print '</div>' print '</div>'
#!/usr/bin/python import cgi import base import home_page_list import exportCard_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() #card_id = form.getvalue('card_id') serial_num = base.cleanCGInumber(form.getvalue('serial_num')) base.header(title='Exporting Card: {0}'.format(serial_num)) base.top() exportCard_functions.export(serial_num) base.bottom()
#!/usr/bin/python import cgi import base from connect import connect import mysql.connector from summary_functions import get, id_from_name import module_functions #cgi header base.begin() base.header(title='ATD: Summary') base.top() List_of_rows = get() print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width: 100%; font-size: 12px">' print '<tbody>' print '<tr>' print "<th style='background-color: #F0F0F0; font-size: 16px;'> S/N </th>" print "<th colspan=2 style='background-color: #F0F0F0; text-align: center; font-size: 16px;'> Tests Remaining </th>" print '<th colspan=2 style="background-color: #D7FFCA; text-align: center; font-size: 16px;"> Tests Passed </th>' print '<th colspan=2 style="background-color: #FFD4D4; text-align: center; font-size: 16px;"> Tests Failed </th>' #print '<th> Final Status </th>' print '</tr>' background_colors = {
#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 print("Content-type: text/html\r\n\r\n") import DB, base, cgi fieldStorage = cgi.FieldStorage() category = fieldStorage.getvalue("category") if category == None: base.header("Deals of the Day") for product in DB.products: base.createProduct(product) else: base.header(category.upper()) for product in DB.products: if category == product["product_category"]: base.createProduct(product) base.footer()
#!/usr/bin/python import cgi import base import home_page_list import add_test_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() card_id = base.cleanCGInumber(form.getvalue('card_id')) serial_num = base.cleanCGInumber(form.getvalue('serial_num')) suggested_test = base.cleanCGInumber(form.getvalue('suggested')) base.header(title='ADT: Add test') base.top() add_test_functions.add_test_template(card_id, serial_num, suggested_test) base.bottom()
import os.path import sys form = cgi.FieldStorage() attach_id = base.cleanCGInumber(form.getvalue('attach_id')) db = connect(0) cur = db.cursor() cur.execute( "SELECT test_id, attachmime, originalname FROM Attachments WHERE attach_id=%d" % (attach_id)) if not cur.with_rows: print "Content-type: text/html\n" base.header("Attachment Request Error") base.top() print "<h1>Attachment not available</h1>" base.bottom() else: thevals = cur.fetchall() attpath = settings.getAttachmentPathFor(thevals[0][0], attach_id) if not os.path.isfile(attpath): print "Content-type: text/html\n" base.header("Attachment Request Error") base.top() print "<h1>Attachment not found</h1>" base.bottom() else: statinfo = os.stat(attpath) print 'Content-type: %s \r\nContent-length: %d \r\nContent-Disposition: INLINE; filename="%s" \n' % (
#!/usr/bin/python import cgi import base import home_page_list import add_test_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() #card_id = form.getvalue('card_id') serial_num = base.cleanCGInumber(form.getvalue('serial_num')) suggested_test = base.cleanCGInumber(form.getvalue('suggested')) base.header(title='Add Test') base.top() add_test_functions.add_test_template(serial_num,suggested_test) base.bottom()
import sys import cgi import base import home_page_list import module_functions from connect import connect #cgi header print "<html>" form = cgi.FieldStorage() card_id = int(sys.argv[1]) serial_num = int(sys.argv[2]) base.header(title='ngCCM ePortage') base.top() #print 'card_id = ', card_id #print 'serial_num = ', serial_num module_functions.add_test_tab(serial_num,card_id) #print '<div class="row">' #print '<div class="col-md-12">' #print '<h2>Test Results for ngCCM %s</h2>' % serial_num #print '</div>' #print '</div>' revokes=module_functions.Portage_fetch_revokes(serial_num) db = connect(0)
#!/usr/bin/python import cgi import base from connect import connect import mysql.connector from testers_functions import get import module_functions #cgi header print "Content-type: text/html\n" base.header(title='Summary') base.top() print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width:650px" align="center">' print '<tr>' print '<th > Name </th>' print '<th > ID </th>' print '</tr>' userInfo = get() for user in userInfo: print '<tr>' print '<td align="left">',user['name'],'</td>' print '<td align="left">',user['id'],'</td>'
#!/usr/bin/python import cgi import base import home_page_list import module_functions from connect import connect # cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() card_id = base.cleanCGInumber(form.getvalue("card_id")) serial_num = base.cleanCGInumber(form.getvalue("serial_num")) base.header(title="uHTR ePortage") base.top() # print 'card_id = ', card_id # print 'serial_num = ', serial_num module_functions.add_test_tab(serial_num, card_id) revokes = module_functions.Portage_fetch_revokes(serial_num) db = connect(0) cur = db.cursor() cur.execute("select test_type, name from Test_Type where required = 1 order by relative_order ASC") for test_type in cur: module_functions.ePortageTest(test_type[0], serial_num, test_type[1], revokes)
def loginSuccessful(userid): base.header(f"Welcome {userid.title()} !!") base.footer()
return not rows==[] def addTestToRevokeList( test_id ) : db = connect(1) cur = db.cursor() cur.execute("INSERT INTO TestRevoke SET test_id=%i,comment='%s'"%(test_id,comments)) db.commit() #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() test_id = base.cleanCGInumber(form.getvalue("test_id")) comments = form.getvalue("comments") base.header(title='Revoke') base.top() print '<br><br>' if not inRevokeList( test_id ) : addTestToRevokeList( test_id ) print 'Done' else : print 'Test already revoked...' base.bottom()
#!/usr/bin/python import cgi import cgitb ; cgitb.enable() import base from connect import connect import mysql.connector from testSetup_functions import get import module_functions #cgi header print "Content-type: text/html\n" base.header(title='Setup') base.top() print '<div class="row">' print '<div class="col-md-12">' print '<table class="table" style="width:100%">' print '<tbody>' print '<tr>' print '<th> Name </th>' print '<th> Description </th>' print '<th> Required? </th>' print '</tr>' testInfo = get() for test in testInfo: print '<tr align=left>'
import cgi import cgitb ; cgitb.enable() from connect import connect import mysql.connector import base #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() testName = form.getvalue("testName","no name found") descShort = form.getvalue("descShort","no description found") descLong = form.getvalue("descLong","no description found") base.header(title='Add Test Type') base.top() db = connect(1) cur = db.cursor() cur.execute("INSERT INTO Test_Type (name,required,desc_short,desc_long,relative_order) VALUES ('{0}',1,'{1}','{2}',1);".format(testName,descShort,descLong)) db.commit() db.close() #else: # print "ERROR occured..." # print testName,",",descShort,",",descLong base.bottom()
#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 import base, DB, cgi, model fieldStorage = cgi.FieldStorage() pid = fieldStorage.getvalue('pid') if pid != None: model.addToCart(int(pid)) base.header("My Cart") # print(f"<p>{DB.productsInCart}</p>") # print(f"<p>{model.getProductsInCart()}</p>") for product in DB.products: for x in model.getProductsInCart(): if x[0] == product['product_id']: base.createProduct(product) print(''' <div class = "row" id="proceedToPaymentBtnParent"> <div class="col-md-2 offset-md-5" id="proceedToPaymentBtn"> <button class="btn btn-primary">Proceed to Payment</button> </div> </div> ''') base.footer()
def registerSuccessful(): base.header("Signup successful !!") base.footer()
#!/usr/bin/python import cgi import base import home_page_list #import add_test_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() test_id = base.cleanCGInumber(form.getvalue('test_id')) #suggested_test = base.cleanCGInumber(form.getvalue('suggested')) base.header(title='Revoke Failure') base.top() print '<br><br>' print 'Revoking test %i from list of valid tests'%test_id print 'Please add any comments about why the test is being revoked:' print '<form action="revokeFormHandler.py" method="post" enctype="multipart/form-data">' print ' <input type="hidden" name="test_id" value=%i>'%test_id print ' <br><br>' print ' <textarea rows="5" cols="100" name="comments"></textarea>' print ' <br><br>' print ' <input type="submit" value="Revoke">' print '</form>' base.bottom()
import cgi import cgitb cgitb.enable() from connect import connect import mysql.connector import base #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() testName = form.getvalue("testName", "no name found") descShort = form.getvalue("descShort", "no description found") descLong = form.getvalue("descLong", "no description found") base.header(title='Add Test Type') base.top() db = connect(1) cur = db.cursor() cur.execute( "INSERT INTO Test_Type (name,required,desc_short,desc_long,relative_order) VALUES ('{0}',1,'{1}','{2}',1);" .format(testName, descShort, descLong)) db.commit() db.close() #else: # print "ERROR occured..." # print testName,",",descShort,",",descLong
def main(): base.begin() # Print the preamble and opening html tag. base.header(title="Acceptance Test Database") # Print the header. base.top() # Print the top portion of the body (title, buttons). This remains the same for every page. print get() base.bottom() # Print footer (if applicable) and closing body and html tags.
model.post(p_data, post_pic, email) print(""" <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <title>Hello, world!</title> <link rel="stylesheet" href="styles.css"> </head> <body> """) base.header(email) print("<div class='container'>") print("<h3>Post Updated</h3>") print(email) print("</div>") print(""" </body> </html> """)
#!/usr/bin/python import cgi import base import home_page_list import module_functions from connect import connect # Deal with URL arguments: form = cgi.FieldStorage() card_id = base.cleanCGInumber(form.getvalue('card_id')) serial_num = base.cleanCGInumber(form.getvalue('serial_num')) # Print basic HTML stuff: base.begin() base.header(title='ATD: Add ID for Board {0}'.format(serial_num)) # Print the header base.top() #print 'card_id = ', card_id #print 'serial_num = ', serial_num print '''\t\t<form method="post" class="sub-id-form" action="add_id2.py"> <div class="row"> <div class="col-md-12"> <h4>Add a unique ID for the board with SN = {0}</h4> </div> </div> <br> <br> <div class="row"> <div class = "col-md-6"> <label class="sub-id"> Unique ID: <input name="unique_id">
import add_test_functions #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() person_id = base.cleanCGInumber(form.getvalue("person_id")) test_type = base.cleanCGInumber(form.getvalue("test_type")) serial_num = base.cleanCGInumber(form.getvalue("serial_number")) success = base.cleanCGInumber(form.getvalue("success")) comments = form.getvalue("comments") if comments: comments = cgi.escape(comments) base.header(title='Add Test') base.top() test_id = add_test_functions.add_test(person_id, test_type, serial_num, success, comments) for itest in (1, 2, 3): afile = form['attach%d' % (itest)] if (afile.filename): adesc = form.getvalue("attachdesc%d" % (itest)) if adesc: adesc = cgi.escape(adesc) acomment = form.getvalue("attachcomment%d" % (itest)) if acomment: acomment = cgi.escape(acomment) add_test_functions.add_test_attachment(test_id, afile, adesc, acomment)
#!/usr/bin/python import cgi import base import home_page_list import module_functions from connect import connect #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() card_id = base.cleanCGInumber(form.getvalue('card_id')) serial_num = base.cleanCGInumber(form.getvalue('serial_num')) base.header(title='ngCCM ePortage') base.top() #print 'card_id = ', card_id #print 'serial_num = ', serial_num module_functions.add_test_tab(serial_num, card_id) revokes=module_functions.Portage_fetch_revokes(serial_num) db = connect(0) cur = db.cursor() cur.execute("select test_type, name , desc_long from Test_Type where required = 1 order by relative_order ASC") for test_type in cur: module_functions.ePortageTest(test_type[0], serial_num, test_type[1], revokes, test_type[2])
def coupons(coupon, totalcart): c = 'spool' if coupon == c: discount = (totalcart * 10) / 100 totalcart = totalcart - (totalcart * 10) / 100 return totalcart, discount else: import base import cgi import model import pymysql form = cgi.FieldStorage() print(form) item = form.getvalue('p_id') print(""" <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> <style> body { background-image : url("http://cdn.osxdaily.com/wp-content/uploads/2011/10/NSTexturedFullScreenBackgroundColor.png"); } h1 { color : #fff; } </style> </head> <body> """) base.header() try: data = model.mycart(item) model.writeMyCart(data) except BaseException as ex: pass data2 = model.getCartData() print(""" <div class="container"> <h1 class="text-center">My CART</h1> <hr> <div class="row"> """) totalcart = 0 for j in range(len(data2)): totalcart = totalcart + int(data2[j][4]) print(""" <div class="col-md-4"> <div class="card text-white bg-dark mb-3" style="width: 18rem;margin-bottom:20px; padding:10px;"> <img src="{}" class="card-img-top" alt="img" height=400> <div class="card-body"> <h5 class="card-title">{}</h5> <p class="card-text">Price : {}</p> <a href="deleteCartController.py?p_id={}" class="btn btn-primary">Delete</a> <a href="productDetails.py?p_id={}" class="btn btn-primary">View Details</a> </div> </div> </div>""".format(data2[j][-1], data2[j][2], data2[j][4], data2[j][0], data2[j][0])) # print("<h3>total cart = {}</h3>".format(totalcart)) # print("<h3>no of products = {}</h3>".format(len(data2))) print(""" <div class="card text-black bg-primary mb-3" style="width: 18rem;margin-bottom:20px; padding:10px;"> <ul class="list-group list-group-flush"> <li class="list-group-item">Number of Products=</li> <li class="list-group-item">Cart Price={}</li> <li class="list-group-item">Invalid Coupon Code</li> <form action="CouponController.py?q={}" method="post"> <div class="form-group"> <label for="coupon">Coupons:</label> <input type="text" class="form-control" id="coupon" name="coupon" placeholder="apply coupon"> </div> <button type="submit" class="btn btn-primary">Apply</button> </form> <li class="list-group-item">Discount=</li> <li class="list-group-item">Total Price=</li> </ul> <div> <a href = "details.py" class = "btn btn-primary">Buy Now</a> </div> </div> """.format(totalcart, totalcart)) base.footer() print(""" </body> </html> """)
import add_test_functions # cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() person_id = base.cleanCGInumber(form.getvalue("person_id")) test_type = base.cleanCGInumber(form.getvalue("test_type")) serial_num = base.cleanCGInumber(form.getvalue("serial_number")) success = base.cleanCGInumber(form.getvalue("success")) comments = form.getvalue("comments") if comments: comments = cgi.escape(comments) base.header(title="Add Test") base.top() test_id = add_test_functions.add_test(person_id, test_type, serial_num, success, comments) for itest in (1, 2, 3): afile = form["attach%d" % (itest)] if afile.filename: adesc = form.getvalue("attachdesc%d" % (itest)) if adesc: adesc = cgi.escape(adesc) acomment = form.getvalue("attachcomment%d" % (itest)) if acomment: acomment = cgi.escape(acomment) add_test_functions.add_test_attachment(test_id, afile, adesc, acomment)
#!/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 print("Content-type: text/html\r\n\r\n") import DB, base, cgi fieldStorage = cgi.FieldStorage() query = fieldStorage.getvalue('q') query = query.lower() for category in DB.searchIntents.keys(): if query in DB.searchIntents[category]: query = category base.header(query.upper()) # print(query) for product in DB.products: if query in product['product_sub_category'] or query in product[ 'product_brand'].lower() or query in product['product_name'].lower( ) or query == product["product_category"]: base.createProduct(product)
#!/usr/bin/python import cgi import base import home_page_list #cgi header print "Content-type: text/html\n" base.header(title='Adding a new module...') base.top() form = cgi.FieldStorage() if form.getvalue('serial_number'): sn = cgi.escape(form.getvalue('serial_number')) #print '<div> Serial Number = %(s)s , )s </div>' %{'s': sn} home_page_list.add_module(sn) print '<div class="row">' print '<div class="col-md-3">' print '<h2>List of All Boards</h2>' print '<b><em>(Sorted by Serial Number)</em></b>' print '</div>' print '<div class="col-md-3">' print '<br><br>' print '<a href="add_module.py">' print '<button type="button">Add a New Board</button>' print '</a>' print '</div>'
from connect import connect import settings import os.path import sys form = cgi.FieldStorage() attach_id = base.cleanCGInumber(form.getvalue('attach_id')) db=connect(0) cur=db.cursor() cur.execute("SELECT test_id, attachmime, originalname FROM Attachments WHERE attach_id=%d" % (attach_id)); if not cur.with_rows: print "Content-type: text/html\n" base.header("Attachment Request Error") base.top() print "<h1>Attachment not available</h1>" base.bottom() else: thevals=cur.fetchall(); attpath=settings.getAttachmentPathFor(thevals[0][0],attach_id) if not os.path.isfile(attpath): print "Content-type: text/html\n" print print attpath base.header("Attachment Request Error") base.top() print "<h1>Attachment not found</h1>" base.bottom() else:
def addTestToRevokeList(test_id): db = connect(1) cur = db.cursor() cur.execute("INSERT INTO TestRevoke SET test_id=%i,comment='%s'" % (test_id, comments)) db.commit() #cgi header print "Content-type: text/html\n" form = cgi.FieldStorage() test_id = base.cleanCGInumber(form.getvalue("test_id")) comments = form.getvalue("comments") base.header(title='Revoke') base.top() print '<br><br>' if not inRevokeList(test_id): addTestToRevokeList(test_id) print 'Done' else: print 'Test already revoked...' base.bottom()