from synapse import Synapse synapse = Synapse() @synapse.connect('/hello') def robo(name, robot=False): if robot: return f"{name} is a robot" else: return f"{name} is not a robot" @synapse.connect('/ok') def ok(okn): return ( f"{okn}" ) # robo('meain') synapse.start(debug=True) # synapse.start()
from synapse import Synapse from sqlalchemy.exc import OperationalError # Initialize database try: db.session.execute("SELECT * FROM 'starmap' LIMIT 1") except OperationalError: app.logger.info("Initializing database") db.create_all() db.session.add(Starmap(app.config['SOMA_ID'])) db.session.commit() if app.config['USE_DEBUG_SERVER']: # flask development server app.run(app.config['LOCAL_HOSTNAME'], app.config['LOCAL_PORT']) else: shutdown = gevent.event.Event() # Synapse app.logger.info("Starting Synapses") synapse = Synapse(('0.0.0.0', app.config['SYNAPSE_PORT'])) synapse.start() # gevent server if not app.config['NO_UI']: app.logger.info("Starting Web-UI") local_server = WSGIServer(('', app.config['LOCAL_PORT']), app) local_server.start() shutdown.wait()