浏览代码

Planner-Webservice verschoben.

Robert Bedner 3 年之前
父节点
当前提交
b67d00e3eb

+ 0 - 0
planner/save/V1_20201012215917.json → planner/save/2021_V1_20201012215917.json


+ 0 - 0
planner/save/V1_20201012215951.json → planner/save/2021_V1_20201012215951.json


+ 0 - 0
planner/save/V1_20201012222955.json → planner/save/2021_V1_20201012222955.json


+ 0 - 0
planner/save/V1_20201013155520.json → planner/save/2021_V1_20201013155520.json


+ 0 - 0
planner/save/V1_20201015133914.json → planner/save/2021_V1_20201015133914.json


+ 0 - 0
planner/save/V1_20201015153543.json → planner/save/2021_V1_20201015153543.json


+ 0 - 0
planner/save/V1_20201119092000.json → planner/save/2021_V1_20201119092000.json


+ 0 - 0
planner/save/V1_20201119163149.json → planner/save/2021_V1_20201119163149.json


+ 0 - 0
planner/save/V1_20201120111717.json → planner/save/2021_V1_20201120111717.json


+ 0 - 0
planner/save/V1_20201213002145.json → planner/save/2021_V1_20201213002145.json


+ 0 - 0
planner/save/V1_20201229194351.json → planner/save/2021_V1_20201229194351.json


+ 0 - 0
planner/save/V2_20201012222955.json → planner/save/2021_V2_20201012222955.json


+ 0 - 0
planner/save/V1_20201012215044.json


+ 0 - 0
webservice/dist/file-io.exe → planner/webservice/dist/file-io.exe


+ 0 - 0
webservice/file_io.bat → planner/webservice/file_io.bat


+ 29 - 6
webservice/file_io.py → planner/webservice/file_io.py

@@ -4,6 +4,8 @@ import json
 from flask_cors import CORS
 from datetime import datetime
 import hashlib
+import time
+
 
 app = Flask(__name__)
 # cors = CORS(app, resources={r"/*": {"origins": "http://localhost:4200/"}})
@@ -20,18 +22,39 @@ def list_json():
 
 
 def list_dict():
-    result = {}
+    result = {'list': [], 'tree': {}}
     for currentFile in save_dir.iterdir():
         if currentFile.is_file() and currentFile.name[-5:] == '.json':
-            name_split = currentFile.name[:-5].split("_")
-            current_list = result.get(name_split[0], [])
-            current_list.append(name_split[1])
-            result[name_split[0]] = current_list
+            year, version, timestamp = currentFile.name[:-5].split("_")
+            if year not in result['tree']:
+                result['tree'][year] = {}
+            if version not in result['tree'][year]:
+                result['tree'][year][version] = []
+            result['tree'][year][version].append(timestamp)
+            result['list'].append({'year': year, 'version': version, 'timestamp': timestamp})
     return result
 
 
+@app.route('/load/<year>/<version>/<timestamp>', methods=['GET'])
+def load(year, version, timestamp):
+    file = full_filename(year, version, timestamp)
+
+    if not Path(file).exists():
+        file_list = list_dict()
+        timestamp = file_list['tree'][year][version][-1]
+        file = full_filename(year, version, timestamp)
+
+    print(file)
+    time.sleep(2)
+    return open(file, 'r').read()
+
+
+def full_filename(year, version, timestamp):
+    return f'{str(save_dir)}/{year}_{version}_{timestamp}.json'
+
+
 @app.route('/load/<filename>', methods=['GET'])
-def load(filename):
+def load_file(filename):
     full_filename = f'{str(save_dir)}/{filename}.json'
     if not Path(full_filename).exists():
         file_list = list_dict()

+ 0 - 0
webservice/file_io.spec → planner/webservice/file_io.spec