Example #1
0
 def get(self):
     args = self.get_args('get')
     post_ = Post.get(args['post_id'])
     author = User.get(post_.user_id).username
     post_data = {
         'title': post_.title,
         'text': post_.text,
         'publish_date': post_.publish_date.strftime('%Y-%m-%d %H:%M:%S'),
         'author': author
     }
     print(post_data)
     return {'status': 200, 'msg': '成功', 'post': post_data}
Example #2
0
async def json_res(request: Request):
    print(request.url)
    print(request.pony_session)

    with request.pony_session:
        Post(title="第一篇文章", content="Hello world")
        commit()

        p = Post.get(post_pk=1)
        # print(p)
        print(p.post_pk, '|', p.title, '|', p.content)

    return Response('{"code":0000,"msg":"OK"}')