-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathauthentication.py
More file actions
27 lines (18 loc) · 800 Bytes
/
authentication.py
File metadata and controls
27 lines (18 loc) · 800 Bytes
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
#!/usr/bin/env python3
#
# Copyright (c) 2020 Gareth Palmer <gareth.palmer3@gmail.com>
# This program is free software, distributed under the terms of
# the GNU General Public License Version 2.
from flask import Blueprint, Response, request
import config
blueprint = Blueprint('authentication', __name__)
@blueprint.route('/authentication')
def cgi_authentication():
username = request.args.get('UserID', '')
password = request.args.get('Password', '')
if username != config.cgi_username or password != config.cgi_password:
return Response('UNAUTHORIZED', mimetype = 'text/plain'), 200
return Response('AUTHORIZED', mimetype = 'text/plain'), 200
@blueprint.errorhandler(Exception)
def error_handler(error):
return Response('ERROR', mimetype = 'text/plain'), 500