You've already forked KemoFureApi
							
							Compare commits
	
		
			2 Commits
		
	
	
		
			testBranch
			...
			2b121be258
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2b121be258 | |||
| eefb47476a | 
							
								
								
									
										2
									
								
								app.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								app.py
									
									
									
									
									
								
							| @@ -3,6 +3,7 @@ from flask_restful import Api | ||||
|  | ||||
| from modules.KF3.database import Database as KF3DB | ||||
| from modules.Kingdom.database import Database as KFKDB | ||||
| from modules.Archive.database import Database as KFADB | ||||
|  | ||||
| app = Flask(__name__) | ||||
| app.config['JSON_AS_ASCII'] = False | ||||
| @@ -12,6 +13,7 @@ api = Api(app) | ||||
|  | ||||
| KF3DB(api) | ||||
| KFKDB(api) | ||||
| KFADB(api) | ||||
|  | ||||
| if __name__ == '__main__': | ||||
|     app.run(host='127.0.0.1', port=8080, debug=True) | ||||
							
								
								
									
										22
									
								
								modules/Archive/database.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								modules/Archive/database.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| import json | ||||
| from .databaseController import DatabaseController | ||||
| from .endpoints.query import Archive_Query | ||||
|  | ||||
| class Database: | ||||
|     db : DatabaseController = None | ||||
|     processed_friends = {} | ||||
|     item_stages = {} | ||||
|  | ||||
|     def __init__(self, api) -> None: | ||||
|         app = api.app | ||||
|         if "Archive" in app.databases: | ||||
|             del app.databases["Archive"] | ||||
|  | ||||
|         self.reload_data() | ||||
|  | ||||
|         app.databases["Archive"] = self | ||||
|  | ||||
|         api.add_resource(Archive_Query, "/Archive/Query") | ||||
|    | ||||
|     def reload_data(self): | ||||
|         self.db = DatabaseController("/home/pi/python/Katbots/JapariArchive/database.db") | ||||
							
								
								
									
										21
									
								
								modules/Archive/databaseController.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								modules/Archive/databaseController.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| import os | ||||
| import sqlite3 | ||||
|  | ||||
| TABLE_ACCOUNTS  = "accounts" | ||||
| TABLE_X         = "x_posts" | ||||
|  | ||||
| class DatabaseController: | ||||
|     def __init__(self, db_name): | ||||
|         self.conn = sqlite3.connect(db_name, isolation_level="DEFERRED") | ||||
|         self.cursor = self.conn.cursor() | ||||
|  | ||||
|     def run_query(self, query): | ||||
|         try: | ||||
|             self.cursor.execute(query) | ||||
|             results = self.cursor.fetchall() | ||||
|             return results | ||||
|         except: | ||||
|             return None | ||||
|  | ||||
|     def close(self): | ||||
|         self.conn.close() | ||||
							
								
								
									
										21
									
								
								modules/Archive/endpoints/query.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								modules/Archive/endpoints/query.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| import json | ||||
| from flask_restful import Resource | ||||
| from flask import current_app as app, jsonify | ||||
|  | ||||
| class Archive_Query(Resource): | ||||
|     def post(self, query:str): | ||||
|         db = app.databases["Archive"] | ||||
|  | ||||
|         result = db.run_query(query) | ||||
|  | ||||
|         if result is None: | ||||
|             response = app.response_class(status=400) | ||||
|         else: | ||||
|             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    | ||||
| @@ -123,7 +123,7 @@ class Database: | ||||
|         chara = {} | ||||
|          | ||||
|         charaData = self.charaData[id] | ||||
|         alphaBase = self.paramAlphaBases[id] | ||||
|         alphaBase = self.paramAlphaBases[id] if id in self.paramAlphaBases else None | ||||
|  | ||||
|         wrLocked = False | ||||
|         promoIds = [] | ||||
| @@ -190,16 +190,23 @@ class Database: | ||||
|         else: | ||||
|             level_curve = self.limitlevel_rising_status[patternId] if patternId != 0 else None | ||||
|  | ||||
|         chara["stats_min"] = get_all_stats(chara, alphaBase, max_level = False, rising_status_pattern=level_curve) | ||||
|         chara["stats_max"] = get_all_stats(chara, alphaBase, max_level = True, rising_status_pattern=level_curve) | ||||
|         chara["plasmPoint"] = alphaBase["plasmPoint"] | ||||
|         chara["cards"] = [ | ||||
|             {"type":alphaBase["orderCardType00"], "value":alphaBase["orderCardValue00"]}, | ||||
|             {"type":alphaBase["orderCardType01"], "value":alphaBase["orderCardValue01"]}, | ||||
|             {"type":alphaBase["orderCardType02"], "value":alphaBase["orderCardValue02"]}, | ||||
|             {"type":alphaBase["orderCardType03"], "value":alphaBase["orderCardValue03"]}, | ||||
|             {"type":alphaBase["orderCardType04"], "value":alphaBase["orderCardValue04"]} | ||||
|         ] | ||||
|         if alphaBase is None: | ||||
|             chara["stats_min"] = {"level" : 0,"status" : 0,"wr" : 0,"hp" : 0,"atk" : 0,"def" : 0,"evd" : 0,"beat" : 0,"act" : 0,"try" : 0} | ||||
|             chara["stats_max"] = {"level" : 0,"status" : 0,"wr" : 0,"hp" : 0,"atk" : 0,"def" : 0,"evd" : 0,"beat" : 0,"act" : 0,"try" : 0} | ||||
|             chara["plasmPoint"] = 0 | ||||
|             chara["cards"] = {0,0,0,0,0} | ||||
|         else: | ||||
|             chara["stats_min"] = get_all_stats(chara, alphaBase, max_level = False, rising_status_pattern=level_curve) | ||||
|             chara["stats_max"] = get_all_stats(chara, alphaBase, max_level = True, rising_status_pattern=level_curve) | ||||
|             chara["plasmPoint"] = alphaBase["plasmPoint"] | ||||
|             chara["cards"] = [ | ||||
|                 {"type":alphaBase["orderCardType00"], "value":alphaBase["orderCardValue00"]}, | ||||
|                 {"type":alphaBase["orderCardType01"], "value":alphaBase["orderCardValue01"]}, | ||||
|                 {"type":alphaBase["orderCardType02"], "value":alphaBase["orderCardValue02"]}, | ||||
|                 {"type":alphaBase["orderCardType03"], "value":alphaBase["orderCardValue03"]}, | ||||
|                 {"type":alphaBase["orderCardType04"], "value":alphaBase["orderCardValue04"]} | ||||
|             ] | ||||
|  | ||||
|         chara["synergy_flag"] = self.paramArts[id]["authParam"]["SynergyFlag"] if id in self.paramArts else 0 | ||||
|          | ||||
|         chara["arts"] = self.paramArts[id] if id in self.paramArts else None | ||||
|   | ||||
		Reference in New Issue
	
	Block a user