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