How to use the fdk.handle function in fdk

To help you get started, we’ve selected a few fdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chryswoods / acquire / services / registry / route.py View on Github external
"""
    if function == "get_service":
        from registry.get_service import run as _get_service
        return _get_service(args)
    elif function == "register_service":
        from registry.register_service import run as _register_service
        return _register_service(args)
    else:
        from admin.handler import MissingFunctionError
        raise MissingFunctionError()


if __name__ == "__main__":
    import fdk
    from admin.handler import create_async_handler
    fdk.handle(create_async_handler(registry_functions))
github fnproject / fn / examples / formats / http / python / func.py View on Github external
"""
    User's request body handler
    :param context: request context
    :type context: hotfn.http.request.RequestContext
    :param data: request body, it's type depends on request Content-Type header
    :type data: object
    :param loop: asyncio event loop
    :type loop asyncio.AbstractEventLoop
    :return: echo of data
    :rtype: object
    """
    return data


if __name__ == "__main__":
    fdk.handle(app)
github chryswoods / acquire / services / accounting / route.py View on Github external
return _get_account_uids(args)
    elif function == "get_info":
        from accounting.get_info import run as _get_info
        return _get_info(args)
    elif function == "perform":
        from accounting.perform import run as _perform
        return _perform(args)
    else:
        from admin.handler import MissingFunctionError
        raise MissingFunctionError()


if __name__ == "__main__":
    import fdk
    from admin.handler import create_async_handler
    fdk.handle(create_async_handler(accounting_functions))
github chryswoods / acquire / services / identity / route.py View on Github external
return _recover_otp(args)
    elif function == "register":
        from admin.register import run as _register
        return _register(args)
    elif function == "request_login":
        from admin.request_login import run as _request_login
        return _request_login(args)
    else:
        from admin.handler import MissingFunctionError
        raise MissingFunctionError()


if __name__ == "__main__":
    import fdk
    from admin.handler import create_async_handler
    fdk.handle(create_async_handler(identity_functions))
github chryswoods / acquire / services / compute / route.py View on Github external
def compute_functions(function, args):
    """These are all of the additional functions for the compute service"""
    from admin.handler import MissingFunctionError
    raise MissingFunctionError()


if __name__ == "__main__":
    import fdk
    from admin.handler import create_async_handler
    fdk.handle(create_async_handler(compute_functions))
github chryswoods / acquire / services / access / route.py View on Github external
if function == "request":
        from access.request import run as _request
        return _request(args)
    elif function == "run_calculation":
        from access.run_calculation import run as _run_calculation
        return _run_calculation(args)
    else:
        from admin.handler import MissingFunctionError
        raise MissingFunctionError()


if __name__ == "__main__":
    import fdk
    from admin.handler import create_async_handler
    fdk.handle(create_async_handler(access_functions))
github fnproject / fdk-python / samples / echo / async / func.py View on Github external
#    under the License.

import fdk
import json


async def handler(ctx, data=None):
    name = "World"
    if data and len(data) > 0:
        body = json.loads(data)
        name = body.get("name")
    return "Hello {0}".format(name)


if __name__ == "__main__":
    fdk.handle(handler)
github fnproject / fdk-python / samples / echo / sync / func.py View on Github external
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import fdk
import json


def handler(ctx, data=None):
    body = json.loads(data) if len(data) > 0 else {"name": "World"}
    return "Hello {0}".format(body.get("name"))


if __name__ == "__main__":
    fdk.handle(handler)
github chryswoods / acquire / services / storage / route.py View on Github external
return _open(args)
    elif function == "open_drive":
        from storage.open_drive import run as _open_drive
        return _open_drive(args)
    elif function == "upload":
        from storage.upload import run as _upload
        return _upload(args)
    else:
        from admin.handler import MissingFunctionError
        raise MissingFunctionError()


if __name__ == "__main__":
    import fdk
    from admin.handler import create_async_handler
    fdk.handle(create_async_handler(storage_functions))