-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (36 loc) · 1.56 KB
/
main.py
File metadata and controls
46 lines (36 loc) · 1.56 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
import argparse
from aiohttp import web
import commands
import v1
async def health(request):
return web.Response(text='OK')
def create_app():
app = web.Application()
# Routes
app.add_routes([
web.get('/api/health/check', health),
# V1
web.post('/api/v1/token/minio', v1.set_token),
web.delete('/api/v1/token/minio', v1.purge_token),
web.post('/api/v1/scan/{type}', v1.scan),
web.post('/api/v1/generate/minio', v1.generate),
web.post('/api/v1/detect/{type}', v1.detect),
])
return app
if __name__ == '__main__':
VERSION = 'v1.3.0'
parser = argparse.ArgumentParser(description='Process bubble sheets.')
parser.add_argument('-v', '--version', action='version', version=f'{VERSION}')
parser.add_argument('-t', '--test', help="show visual result for debug.", action="store_true")
parser.add_argument('-T', '--token', help="generate a url_safe token.", action="store_true")
parser.add_argument('-s', '--set', help="set up a token for minio endpoint", action="store_true")
parser.add_argument('-l', '--dump', help="show available credentials and tokens", action="store_true")
parser.add_argument('-p', '--port', help="accept port number defaults to 8080", default=8080, type=int)
args = parser.parse_args()
command_list = ['test', 'token', 'set', 'dump']
for command in command_list:
if getattr(args, command, None):
getattr(commands, command)()
exit()
print(f'server starting {VERSION}')
web.run_app(create_app(), port=args.port)