-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_app.py
35 lines (32 loc) · 1.23 KB
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from flask import Flask, make_response, render_template, request
from app_utils import token_required
from app import app as auth_app
from bio_auth.check_credentials import checkBioImage
@auth_app.route('/test_server', methods = ['GET', 'POST'])
@token_required
def test_server(*args, **kwargs): # kwargs => username = None
'''
Home Page of Test App server which requires Authorization.
'''
if(request.method == 'POST'):
imageFile = request.files['image']
accept = ['jpg', 'png', 'jpeg', 'gif', 'bmp']
if( imageFile is not None and
imageFile.filename.rsplit('.', 1)[1].lower() in accept
):
username = kwargs['username']
bioImage = imageFile.read()
imageFile.close()
if(checkBioImage(username, bioImage)):
return render_template("test_server.html", username = username), 401
else:
return make_response(
'''
Bio Hash is not verified.
<a href="/test_server"><button >Try Again</button></a>
''',
401
)
return render_template("test_form.html"), 200 # GET
if __name__ == '__main__':
pass