Ejemplo n.º 1
0
def get_article():
    form = json.loads(request.get_data(as_text=True))
    article = Article.find_by(chapter_id=form["chapter_id"])
    if article == None:
        article = Article()
        article.title = "空"
        article.content = "当前章节没有文章,请直接刷题"
        return Response(json.dumps(article.__dict__, ensure_ascii=False), content_type='application/json')
    else:
        return Response(json_util.dumps(article.__dict__, ensure_ascii=False), content_type='application/json')
Ejemplo n.º 2
0
TA.label = "#test1"
TA.save()
CA = Category()
CA.label = "test1"
CA.save()
US = User()
US.password = "******"
US.first_name = "test1 "
US.phone_number = 0000
US.save()

AR = Article()
AR.user_id = US.id
AR.tag_id = TA.id
AR.category_id = CA.id
AR.title = "tets"
AR.description = " walaaaaaaaaaaaaaaaaaaaah test"
AR.content = "nammi test"
AR.version = "test"
AR.promoted = 1
AR.save()
print(TA.to_dict())
print("------------------------------------------------")
print("\n")

print(CA.to_dict())
print("------------------------------------------------")
print("\n")

print(US.to_dict())
print("------------------------------------------------")