Skip to content

person_endpoint

examples.person_endpoint

Attributes

app module-attribute

app = LightApi(initialize_callback=initialize, initialize_arguments={'param1': 'value1'})

Classes

Person

Bases: Base

Source code in examples/person_endpoint.py
class Person(Base):
    name = Column(String)
    email = Column(String, unique=True)
    email_verified = Column(Boolean, default=False)

    def serialize(self) -> dict:
        data = super().serialize()
        return {'data': data}
Attributes
name class-attribute instance-attribute
name = Column(String)
email class-attribute instance-attribute
email = Column(String, unique=True)
email_verified class-attribute instance-attribute
email_verified = Column(Boolean, default=False)
Functions
serialize
serialize() -> dict
Source code in examples/person_endpoint.py
def serialize(self) -> dict:
    data = super().serialize()
    return {'data': data}

Company

Bases: Base

Source code in examples/person_endpoint.py
class Company(Base):
    name = Column(String)
    email = Column(String, unique=True)
    website = Column(String)
Attributes
name class-attribute instance-attribute
name = Column(String)
email class-attribute instance-attribute
email = Column(String, unique=True)
website class-attribute instance-attribute
website = Column(String)

CustomEndpoint

Bases: RestEndpoint

Source code in examples/person_endpoint.py
class CustomEndpoint(RestEndpoint):
    http_method_names = ['GET', 'POST']
    tablename = 'custom'

    def get(self, request):
        return {'message': 'GET'}

    def post(self, request):
        return {'message': 'POST'}
Attributes
http_method_names class-attribute instance-attribute
http_method_names = ['GET', 'POST']
tablename class-attribute instance-attribute
tablename = 'custom'
Functions
get
get(request)
Source code in examples/person_endpoint.py
def get(self, request):
    return {'message': 'GET'}
post
post(request)
Source code in examples/person_endpoint.py
def post(self, request):
    return {'message': 'POST'}

Functions

initialize

initialize(**kwargs)
Source code in examples/person_endpoint.py
def initialize(**kwargs):
    print(f'My pre configuration with {kwargs} parameters')