-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI-Authentication.py
More file actions
33 lines (27 loc) · 1004 Bytes
/
API-Authentication.py
File metadata and controls
33 lines (27 loc) · 1004 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
28
29
30
31
32
33
from bottle import route, run, template, request
@route('/')
def index():
return ('<b>Hi</b>!')
#to test point: http://localhost:8080/
@route('/about')
def about():
return ('<b>About Page</b>!')
#to test point: http://localhost:8080/about
@route('/secrets')
def secret():
try:
key = request.headers["AUTHENTICATION"]
page_info = secretchecker(key)
return (page_info)
except KeyError:
return ("<b> You'll need permission to be here.</b>")
#to test point: http://localhost:8080/secrets
def secretchecker(lock):
if lock == '11':
msg = ("<b> Unlimited powah. </b><br> You're an unlimited user. Here's your unlimited info </b><br> <br> Huzza!</br>")
elif lock == '22':
msg = ("<b> You are limited. </b><br> You're a limited user. Seeing limited info </b>")
else:
msg = ("<b> You need the right keys. </b>")
return msg
run(reloader=True, debug=True, host='localhost', port=8080)