Update app.py
Browse files
app.py
CHANGED
@@ -98,13 +98,14 @@ def enemy_fn(inp):
|
|
98 |
|
99 |
def save_game(background_img,star_img,enemy_img,platform_img,dude_img):
|
100 |
user_repo=save_data.split('datasets/',1)[1].split('/raw',1)[0]
|
101 |
-
out_lod=[]
|
102 |
try:
|
103 |
r = requests.get(f'{save_data}game_data.json')
|
104 |
lod = json.loads(r.text)
|
105 |
-
out_lod.append(lod)
|
106 |
print (out_lod)
|
107 |
except:
|
|
|
108 |
pass
|
109 |
timestamp=str(datetime.datetime.now())
|
110 |
timename=timestamp.replace(" ","--").replace(":","-").replace(".","-")
|
@@ -142,7 +143,7 @@ def save_game(background_img,star_img,enemy_img,platform_img,dude_img):
|
|
142 |
except Exception as e:
|
143 |
print (e)
|
144 |
pass
|
145 |
-
block = {'index': len(
|
146 |
'timestamp': timestamp,
|
147 |
'background_url': f'https://huggingface.co/datasets/{user_repo}/resolve/main/images/background/{timename}-background_img.png',
|
148 |
'star_url': f'https://huggingface.co/datasets/{user_repo}/resolve/main/images/star/{timename}-star_img.png',
|
@@ -151,9 +152,9 @@ def save_game(background_img,star_img,enemy_img,platform_img,dude_img):
|
|
151 |
#'dude_url': f'https://huggingface.co/datasets/{repo}/{space}/raw/main/{dude_img}',
|
152 |
}
|
153 |
print(block)
|
154 |
-
|
155 |
|
156 |
-
json_object = json.dumps(
|
157 |
with open("tmp1.json", "w") as outfile:
|
158 |
outfile.write(json_object)
|
159 |
try:
|
|
|
98 |
|
99 |
def save_game(background_img,star_img,enemy_img,platform_img,dude_img):
|
100 |
user_repo=save_data.split('datasets/',1)[1].split('/raw',1)[0]
|
101 |
+
#out_lod=[]
|
102 |
try:
|
103 |
r = requests.get(f'{save_data}game_data.json')
|
104 |
lod = json.loads(r.text)
|
105 |
+
#out_lod.append(lod)
|
106 |
print (out_lod)
|
107 |
except:
|
108 |
+
lod=[]
|
109 |
pass
|
110 |
timestamp=str(datetime.datetime.now())
|
111 |
timename=timestamp.replace(" ","--").replace(":","-").replace(".","-")
|
|
|
143 |
except Exception as e:
|
144 |
print (e)
|
145 |
pass
|
146 |
+
block = {'index': len(lod) + 1,
|
147 |
'timestamp': timestamp,
|
148 |
'background_url': f'https://huggingface.co/datasets/{user_repo}/resolve/main/images/background/{timename}-background_img.png',
|
149 |
'star_url': f'https://huggingface.co/datasets/{user_repo}/resolve/main/images/star/{timename}-star_img.png',
|
|
|
152 |
#'dude_url': f'https://huggingface.co/datasets/{repo}/{space}/raw/main/{dude_img}',
|
153 |
}
|
154 |
print(block)
|
155 |
+
lod.append(block)
|
156 |
|
157 |
+
json_object = json.dumps(lod, indent=4)
|
158 |
with open("tmp1.json", "w") as outfile:
|
159 |
outfile.write(json_object)
|
160 |
try:
|