You've already forked KemoFureApi
							
							KF3: Api additions and improvements.
This commit is contained in:
		
							
								
								
									
										25
									
								
								endpoints/Kingdom/friend.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								endpoints/Kingdom/friend.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| from flask_restful import Resource | ||||
| from flask import current_app as app | ||||
| from flask import request | ||||
|  | ||||
| class Kingdom_Friend(Resource): | ||||
|     def get(self, id:int): | ||||
|         if "wiki" in request.args: | ||||
|             result = app.databases["Kingdom"].get_chara_wiki(id) | ||||
|  | ||||
|             response = app.response_class( | ||||
|                 response=result, | ||||
|                 status=200, | ||||
|                 mimetype='text/plain' | ||||
|             ) | ||||
|         else: | ||||
|             result = app.databases["Kingdom"].get_chara(id) | ||||
|  | ||||
|             response = app.response_class( | ||||
|                 response=result, | ||||
|                 status=200, | ||||
|                 mimetype='application/json' | ||||
|             ) | ||||
|  | ||||
|         response.headers.add("Access-Control-Allow-Origin", "*") | ||||
|         return response   | ||||
							
								
								
									
										21
									
								
								endpoints/Kingdom/friends.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								endpoints/Kingdom/friends.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| 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    | ||||
							
								
								
									
										16
									
								
								endpoints/Kingdom/item.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								endpoints/Kingdom/item.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| from flask_restful import Resource | ||||
| from flask import current_app as app | ||||
| from flask import request | ||||
|  | ||||
| class Kingdom_Item(Resource): | ||||
|     def get(self, id:int): | ||||
|         result = app.databases["Kingdom"].get_item(id) | ||||
|  | ||||
|         response = app.response_class( | ||||
|             response=result, | ||||
|             status=200, | ||||
|             mimetype='application/json' | ||||
|         ) | ||||
|  | ||||
|         response.headers.add("Access-Control-Allow-Origin", "*") | ||||
|         return response   | ||||
							
								
								
									
										23
									
								
								endpoints/Kingdom/items.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								endpoints/Kingdom/items.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| import json | ||||
| from flask_restful import Resource | ||||
| from flask import current_app as app, jsonify | ||||
|  | ||||
| class Kingdom_Items(Resource): | ||||
|     def get(self): | ||||
|         db = app.databases["Kingdom"] | ||||
|         result = [] | ||||
|         for key in db.kfk_en_item.indexed_data.keys(): | ||||
|             new_value = db.kfk_en_item.indexed_data[key] | ||||
|             new_value["id"] = key | ||||
|             result.append(new_value) | ||||
|  | ||||
|         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    | ||||
		Reference in New Issue
	
	Block a user