from serverapi import api all_api_funcs = api.find_functions(name="*", context="*") from config import config server = PyRpcServer(port=17887, debug=config["debug_enabled"]) # share all api in http://localhost:17887/rpc/ bp = PyRpcBlueprint(name="api", prefix="/rpc") bp.add(all_api_funcs) server.add(bp) # create a parser for all api parser = PyApiParser() parser.pool = all_api_funcs # show a terminal for all api in http://localhost:17887/term tbp = PyRpcTerminal(name="", prefix="/") tbp.handler = parser.parse_extended server.add(tbp) if __name__ == "__main__": # just run the server server.run() from storage import close_everything close_everything()
from game import game from gameapi import game_api from pyapimaker import PyApiParser parser = PyApiParser(only_names=True) quit = False if __name__ == "__main__": print("Welcome to super boring tic tac toe") while not quit: cmd = input("tictactoe-{}> ".format(game.context)) parser.pool = game_api.find_functions(context=game.context) resp = parser.parse_call(cmd) if resp == "no function found": resp = "what did you say" if resp: print(resp) if game.context is None: quit = True
from pyapimaker import PyRpcTerminal, PyApiParser from serverapi import api all_api_funcs = api.find_functions(name="*", context="*") from config import config server = PyRpcServer(port=17887, debug=config["debug_enabled"]) # share all api in http://localhost:17887/rpc/ bp = PyRpcBlueprint(name="api", prefix="/rpc") bp.add(all_api_funcs) server.add(bp) # create a parser for all api parser = PyApiParser() parser.pool = all_api_funcs # show a terminal for all api in http://localhost:17887/term tbp = PyRpcTerminal(name="", prefix="/") tbp.handler = parser.parse_extended server.add(tbp) if __name__ == "__main__": # just run the server server.run() from storage import close_everything close_everything()