Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
if len(sys.argv) != 2:
print("Usage: python3 deploy.py ")
exit()
page_spec = sys.argv[1]
# Launch the services
page_service_proc = start_services(page_spec)
dispatcher = wsgi.WSGIPathInfoDispatcher({'/': app})
server = wsgi.WSGIServer(('0.0.0.0', 8080), wsgi_app=dispatcher)
try:
server.start()
except KeyboardInterrupt:
server.stop()
page_service_proc.terminate()
ssl_crt = apiopts.get('ssl_crt', '')
ssl_key = apiopts.get('ssl_key', '')
verify_certs(ssl_crt, ssl_key)
app = build_app()
app.secret_key = apiopts.get('secret')
if not app.secret_key:
raise Exception("Config setting 'secret_key' must be set for '{0}'"
.format(__name__))
if debug:
app.run(host='0.0.0.0', port=port, debug=True)
else:
ssl_a = cheroot.ssllib.ssl_builtin.BuiltinSSLAdapter(ssl_crt, ssl_key)
wsgi_d = cheroot.wsgi.WSGIPathInfoDispatcher({'/': app})
server = cheroot.wsgi.WSGIServer(('0.0.0.0', port),
wsgi_app=wsgi_d,
ssl_adapter=ssl_a)
try:
server.start()
except KeyboardInterrupt:
server.stop()
def run(self):
wsgi_app_https = ReverseProxied(ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': app})))
bind_addr = (self.config['listen'], self.config['port'])
self.server = wsgi.WSGIServer(bind_addr=bind_addr, wsgi_app=wsgi_app_https)
if self.config['certificate'] and self.config['private_key']:
logger.warning(
'Using service SSL configuration is deprecated. Please use NGINX instead.'
)
self.server.ssl_adapter = http_helpers.ssl_adapter(
self.config['certificate'], self.config['private_key'],
)
logger.debug(
'WSGIServer starting... uid: %s, listen: %s:%s',
os.getuid(),
bind_addr[0],
bind_addr[1],
)