21 lines
763 B
Python
21 lines
763 B
Python
|
import json
|
||
|
from flask_restful import Resource
|
||
|
from flask import current_app as app, jsonify
|
||
|
|
||
|
class Kingdom_Friends(Resource):
|
||
|
def get(self):
|
||
|
db = app.databases["Kingdom"]
|
||
|
result = []
|
||
|
for value in db.processed_friends.values():
|
||
|
result.append({"id": value["sn"], "name": value["name"], "describe": value["describe"]["content"] if "content" in value["describe"] else ""})
|
||
|
|
||
|
result = sorted(result, key=lambda f: f["id"])
|
||
|
|
||
|
response = app.response_class(
|
||
|
response=json.dumps(result, ensure_ascii=False, indent=1),
|
||
|
status=200,
|
||
|
mimetype='application/json'
|
||
|
)
|
||
|
response.headers.add("Access-Control-Allow-Origin", "*")
|
||
|
|
||
|
return response
|