-
Notifications
You must be signed in to change notification settings - Fork 29
/
browser_web.py
39 lines (29 loc) · 1017 Bytes
/
browser_web.py
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
import subprocess, sys
from flask import Flask
app = Flask(__name__, static_folder='css')
registry_endpoint = ""
ssl = ""
@app.route('/registry/search')
def get_docker_registry():
p = subprocess.Popen(['python', 'browser.py', registry_endpoint, 'html', 'all', ssl], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
return out
@app.route('/css/<path:path>')
def send_js(path):
print path
return send_from_directory(app.static_folder, path)
def usage():
return "Usage: browser_web.py <registry_endpoint> <ssl> <ui_url> <ui_port>"
if __name__ == '__main__':
commandlineargs = sys.argv[1:]
len_sys_argv = len(commandlineargs)
if len_sys_argv < 2:
print usage()
else:
registry_endpoint = commandlineargs[0]
ssl = commandlineargs[1]
ui_url = commandlineargs[2]
ui_port = commandlineargs[3]
print 'registry endpoint to use : ' + registry_endpoint, ssl
print 'starting registry ui at : ' + ui_url + ":" + ui_port
app.run(host=ui_url, port=int(ui_port))