Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
71 lines (57 loc) · 2.07 KB
/
Copy pathmain.py
File metadata and controls
71 lines (57 loc) · 2.07 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import importlib
import os
from quart import Quart, jsonify, abort, request
api_keys = os.getenv('API_KEYS', 'hello_world').split(',')
app = Quart(__name__)
# Get all endpoints
for file in os.listdir('render'):
if file.endswith('.py'):
lib = importlib.import_module(f"render.{file[:-3]}")
app.register_blueprint(getattr(lib, 'blueprint'))
# for blpr in app.iter_blueprints():
# print(blpr)
no_auth_paths = ['/', '/filter']
@app.before_request
async def before():
# check for a blueprint, makes sure we have a route
if request.blueprint is not None and request.path not in no_auth_paths:
if 'Authorization' not in request.headers:
abort(401, 'Not Authorized')
return
auth_header = request.headers.get('Authorization')
if auth_header not in api_keys:
abort(401, 'Not Authorized')
@app.route('/')
def home():
# TODO: automate this
# text in function can be obtained via __doc__
return jsonify({
"endpoints": [
"GET /achievement?text=text[&icon=int]",
"GET /challenge?text=text[&icon=int]",
"GET /amiajoke?image=url",
"GET /bad?image=url",
"GET /calling?text=text",
"GET /captcha?text=text",
"GET /didyoumean?top=text&bottom=text",
"GET /drake?top=text&bottom=text",
"GET /facts?text=text",
"GET /filter",
"GET /floor?image=url&text=text",
"GET /fml",
"GET /jokeoverhead?image=url",
"GET /trash?face=url&trash=url",
"GET /pornhub?text=text&text2=text",
"GET /salty?image=url",
"GET /scroll?text=text",
"GET /shame?image=url",
"GET /ship?user=url&user2=url",
"GET /what?image=url"
],
"original": {
"created_by": "AlexFlipnote",
"repo": "https://github.com/AlexFlipnote/alex_api_archive",
}
})
if __name__ == "__main__":
app.run()