-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.py
More file actions
32 lines (22 loc) · 879 Bytes
/
api.py
File metadata and controls
32 lines (22 loc) · 879 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
from flask import Blueprint
from proxy import passthrough, proxy_login
api = Blueprint('api', __name__, url_prefix='/api.app/v1')
@api.route('/', defaults={'path': ''})
@api.route('/<path:path>', methods=['GET'])
async def do_get(path):
return await passthrough(path=path)
@api.route('/', defaults={'path': ''}, methods=['POST'])
@api.route('/<path:path>', methods=['POST'])
async def do_post(path):
if path == 'oauth/token':
return await proxy_login(path=path)
else:
return await passthrough(path=path)
@api.route('/', defaults={'path': ''}, methods=['DELETE'])
@api.route('/<path:path>', methods=['DELETE'])
async def do_delete(path):
return await passthrough(path=path)
@api.route('/', defaults={'path': ''}, methods=['PUT'])
@api.route('/<path:path>', methods=['PUT'])
async def do_put(path):
return await passthrough(path=path)