from pyapimaker import PyRpcServer, PyRpcBlueprint from ast import literal_eval myapi = PyApi() @myapi.add() def foo_a(): print("foo_a is doing thing on serverside") return ("things done") @myapi.add() def foo_b(li, num): print("foo_b is doing something on serverside") li = literal_eval(li) return [s + str(num) for s in li] if __name__ == "__main__": s = PyRpcServer(port=17887) bp = PyRpcBlueprint(name="web", prefix="/rpc") bp.add(myapi.find_functions(), only_names=True) s.add(bp) s.run()
from pyapimaker import PyRpcServer, PyRpcBlueprint from ast import literal_eval myapi = PyApi() @myapi.add() def foo_a(): print("foo_a is doing thing on serverside") return("things done") @myapi.add() def foo_b(li, num): print("foo_b is doing something on serverside") li = literal_eval(li) return [s + str(num) for s in li] if __name__ == "__main__": s = PyRpcServer(port=17887) bp = PyRpcBlueprint(name="web", prefix="/rpc") bp.add(myapi.find_functions(), only_names=True) s.add(bp) s.run()
from pyapimaker import PyRpcServer, PyRpcBlueprint 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 pyapimaker import PyRpcServer, PyRpcBlueprint 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()