コード例 #1
0
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()
コード例 #2
0
ファイル: test_server.py プロジェクト: Jbat1Jumper/PyApiMaker
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()
コード例 #3
0
ファイル: launch.py プロジェクト: Jbat1Jumper/PyApiMaker
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()
コード例 #4
0
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()