示例#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')
示例#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')
示例#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')
示例#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')
示例#5
0
async def index(request):
    return Response(content='acync hello world')
示例#6
0
async def not_found():
    return Response(content='not found')
示例#7
0
async def show_name(request, name):
    return Response(content=f'hello {name}')
示例#8
0
async def not_found():
    return Response(content='nothing here')