Ejemplo n.º 1
0
async def get_todo_details(request, id):
    """get all info about a todo
    """
    async with db_connection_pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute(SELECT_SQL, (todo_json['wechat_uuid']))
            res = await cur.fetchall()
    return Response(content='acync hello world')
Ejemplo n.º 2
0
async def get_todos_list(request):
    """get all todo's uuid and title
    """
    async with db_connection_pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute(SELECT_ALL_SQL)
            res = await cur.fetchall()
    return Response(content='New Todo')
Ejemplo n.º 3
0
async def create_todo(request):
    """create a new todo instance store in db and return 
    the uuid of it in response body
    """
    todo_json = ujson.loads(request.content)
    todo = Todo(str(new_uuid), todo_json['title'], todo_json['content'],
                todo_json['wechat_uuid'])
    async with db_connection_pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute(DELETE_SQL, (todo_json['uuid']))
        await conn.commit()
    return Response(content='Delete Todo')
Ejemplo n.º 4
0
async def create_todo(request):
    """create a new todo instance store in db and return 
    the uuid of it in response body
    """
    todo_json = ujson.loads(request.content)
    new_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, 'todo.cykrt.me')
    todo = Todo(str(new_uuid), todo_json['title'], todo_json['content'],
                todo_json['wechat_uuid'])
    async with db_connection_pool.acquire() as conn:
        async with conn.cursor() as cur:
            await cur.execute(INSERT_SQL,
                              (str(new_uuid), todo_json['wechat_uuid'],
                               todo_json['title'], todo_json['content']))
        await conn.commit()
    return Response(content='POST')
Ejemplo n.º 5
0
async def index(request):
    return Response(content='acync hello world')
Ejemplo n.º 6
0
async def not_found():
    return Response(content='not found')
Ejemplo n.º 7
0
async def show_name(request, name):
    return Response(content=f'hello {name}')
Ejemplo n.º 8
0
async def not_found():
    return Response(content='nothing here')