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()
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],
)
for route in http_helpers.list_routes(app):
logger.debug(route)
@app.route('/status/')
def redirect_to_wiki():
logging.debug("Visit https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/wiki/UNICORN-"
"Monitoring-API-Service for further information!")
return redirect("https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/wiki/"
"UNICORN-Monitoring-API-Service", code=302)
api = Api(app)
api.add_resource(BinanceWebSocketApiRestServer,
"/status//",
"/status//",
resource_class_kwargs={'handler_binance_websocket_api_manager': self,
'warn_on_update': warn_on_update})
try:
dispatcher = wsgi.PathInfoDispatcher({'/': app})
self.monitoring_api_server = wsgi.WSGIServer((host, port), dispatcher)
self.monitoring_api_server.start()
except RuntimeError as error_msg:
logging.error("monitoring API service is going down! - info: " + str(error_msg))
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 bind(self):
name = "Aspen! Cheroot!"
self.cheroot_server = cheroot.wsgi.WSGIServer( self.website.network_address
, server_name=name
, wsgi_app=self.website
)