create_account.py |
| <---Back |
Select Code Highlighting Style: BRIGHT | Seashell | Darkness |
Select Font Size: Small | Normal | Large |
1 #!/usr/bin/python2 2 3 ####################################### 4 # 5 # This script creates new user accounts 6 # 7 # Version: 1.1 8 # 9 ####################################### 10 11 #import everything from qalib.py - this is our library for test functions 12 13 from qalib import * 14 15 #get dictionary of values from web form 16 17 form = cgi.FieldStorage() 18 19 #run_flag is a flag. If run_flag == 1, we create new account 20 21 try: 22 run_flag = form['run_flag'].value 23 except: 24 run_flag = 0 25 26 #function to display first page 27 28 def page_one(message=''): 29 30 html = """<center> 31 32 <h2>Account Creator</h2> 33 34 <p><font color='red'><b>%s</b></font> 35 36 <form action='./create_account.py'> 37 38 <input type='hidden' name='run_flag' value='1'> 39 40 <p><input type='submit' value='Create new user account'> 41 42 </form> 43 44 """ % message 45 46 return html 47 48 #function to display second page 49 50 def page_two(): 51 52 main_list = create_account() 53 54 html = """ 55 56 <center> 57 58 <h3>Here is your test user account*</h3> 59 60 <table border=1 cellpadding=3> 61 62 <tr align='center'> 63 64 <td>First name</td><td>Last name</td><td>Email</td><td>Password</td><td>ZIP code</td><td>Street address</td><td>City</td><td>State</td><td>Country</td> 65 66 </tr> 67 68 <tr align='center'> 69 70 <td>%s</td> <td>%s</td> <td><span><b>%s</b></span></td> <td>1111</td><td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td><td>%s</td> 71 72 </tr> 73 74 </table> 75 76 <br> 77 78 <FORM action='./log_in.py'> 79 80 <input type='hidden' name='email' value='%s'> 81 82 <input type='hidden' name='password' value='1111'> 83 84 <INPUT TYPE="submit" VALUE="Auto Login"> 85 86 </FORM> 87 88 </center> 89 90 <p><i>*this user account will be deleted from DB at 00 minutes next hour. \ 91 For example, if now it's 14:12, it'll be deleted at 15:00</i>""" % \ 92 (main_list[0],main_list[1],main_list[2],main_list[3],main_list[4], \ 93 main_list[5],main_list[6],main_list[7],main_list[2]) 94 95 96 return html 97 98 print 'Content-Type: text/html\n\n' 99 100 101 if int(run_flag) == 0: 102 103 html = page_one() 104 105 else: 106 107 html = page_two() 108 109 html = get_qa_html(html,1) 110 111 print html 112