def runclient(host, port): """ 启动客户端 """ from client.client import create_app app = create_app(host, port) app.run()
def runserver(host, port): """ 启动服务器 """ from server.server import create_app app = create_app() app.run(host, port)
def create_app(self): """ create app Returns: flask app object """ self.app = create_app("sqlite:///", True) self.app.config["TESTING"] = True self.app.config['PRESERVE_CONTEXT_ON_EXCEPTION'] = False return self.app
import sys from server import server from server.setup import init_db, nuke_server """ Entry point to the Server Arguments: -db initializes the database tables and inserts base data -nuke deletes all files in the images folder and resets the database """ if __name__ == '__main__': if len(sys.argv) > 1: if sys.argv[1] == '-db': init_db() elif sys.argv[1] == '-nuke': nuke_server() else: server.create_app().run(host='0.0.0.0')
#!/usr/bin/env python3 import sys from server.server import create_app from server.persistence.helpers import read_json if __name__ == "__main__": config = read_json(sys.argv[1]) bottle_path = sys.argv[2] create_app(config, bottle_path).run(**config.get('host', {'debug': True}))