add example for testing

This commit is contained in:
KF7EEL 2021-05-07 09:01:48 -07:00
parent f1541c7d7d
commit bc2b146f79

View File

@ -20,11 +20,20 @@ def gen():
#content = Markup('<strong>The HTML String</strong>') #content = Markup('<strong>The HTML String</strong>')
user_id = request.args.get('user_id') user_id = request.args.get('user_id')
print(user_id) print(user_id)
auth_dict[int(user_id)] = '' print(request.args.get('mode'))
content = ''' if request.args.get('mode') == 'generated':
auth_dict.update({int(user_id):''})
content = '''
<p style="text-align: center;">Your passphrase for <strong>''' + str(user_id) + '''</strong>:</p> <p style="text-align: center;">Your passphrase for <strong>''' + str(user_id) + '''</strong>:</p>
<p style="text-align: center;"><strong>''' + str(gen_passphrase(int(user_id))) + '''</strong></p> <p style="text-align: center;"><strong>''' + str(gen_passphrase(int(user_id))) + '''</strong></p>
''' '''
if request.args.get('mode') == 'legacy':
auth_dict.update({int(user_id):0})
content = '''<p style="text-align: center;">Using legacy auth</p>'''
if request.args.get('mode') == 'custom':
auth_dict.update({int(user_id):str(request.args.get('custom'))})
content = '''<p style="text-align: center;">Using custom auth passphrase: ''' + request.args.get('custom') + '''</p>'''
print(auth_dict) print(auth_dict)
@ -36,31 +45,40 @@ def gen():
def index(): def index():
#content = Markup('<strong>The HTML String</strong>') #content = Markup('<strong>The HTML String</strong>')
content = ''' content = '''
<table style="width: 600px; margin-left: auto; margin-right: auto;" border="3"> <table style="width: 600px; margin-left: auto; margin-right: auto;" border="3">
<tbody> <tbody>
<tr> <tr>
<td><form action="gen" method="get"> <td><form action="gen" method="get">
<table style="margin-left: auto; margin-right: auto;"> <table style="margin-left: auto; margin-right: auto;">
<tbody> <tbody>
<tr style="height: 62px;"> <tr style="height: 62px;">
<td style="text-align: center; height: 62px;"> <td style="text-align: center; height: 62px;">
<h2><strong><label for="user_id">Generate Passphrase</label></strong></h2> <h2><strong><label for="user_id">DMR ID</label></strong></h2>
</td> </td>
</tr> </tr>
<tr style="height: 51.1667px;"> <tr style="height: 51.1667px;">
<td style="height: 51.1667px;"><input id="user_id" name="user_id" type="text" /></td> <td style="height: 51.1667px; text-align: center;"><input id="user_id" name="user_id" type="text" /></td>
</tr> </tr>
<tr style="height: 27px;"> <tr style="height: 51.1667px;">
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td> <td style="height: 51.1667px; text-align: center;"><select name="mode">
</tr> <option selected="selected" value="generated">Generated Passphrase</option>
</tbody> <option value="legacy">Legacy</option>
</table> <option value="custom">Custom</option>
</form></td> </select></td>
</tr>
<tr style="height: 51.1667px;">
</tr> <td style="height: 51.1667px;">Custom Password (only use if custom is selected): <input id="custom" name="custom" type="text" /></td>
</tbody> </tr>
</table> <tr style="height: 27px;">
<td style="text-align: center; height: 27px;"><input type="submit" value="Submit" /></td>
</tr>
</tbody>
</table>
</form></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
''' '''
@ -70,6 +88,7 @@ def index():
def auth(): def auth():
hblink_req = request.json hblink_req = request.json
print((hblink_req)) print((hblink_req))
print(auth_dict)
if hblink_req['secret'] in shared_secrets: if hblink_req['secret'] in shared_secrets:
if hblink_req['id'] in auth_dict: if hblink_req['id'] in auth_dict:
if auth_dict[hblink_req['id']] == 0: if auth_dict[hblink_req['id']] == 0: