Example #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()
Example #2
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()
Example #3
0
@api.add()
def get_random_text():
    from random import randint
    n = randint(10, 20)
    s = ""
    for ne in range(n):
        le = randint(3, 10)
        for lee in range(le):
            s += chr(randint(97, 122))
        s += " "
    s += "eof."
    return s


@api.add()
def get_server_title():
    return "Hiper mega test server 2000"


if __name__ == "__main__":

    s = PyRpcServer(port=16319)

    bp = PyRpcBlueprint(name="web", prefix="/rpc", acao="*")

    bp.add(api.find_functions(), only_names=True)

    s.add(bp)

    s.run()
Example #4
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()
Example #5
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()