Update app.py
Browse files
app.py
CHANGED
@@ -104,7 +104,7 @@ def enemy_fn(inp):
|
|
104 |
out_url = f'https://omnibus-game-test.hf.space/file={out_file}'
|
105 |
return out,out_url,outrs
|
106 |
|
107 |
-
def save_game(name,score
|
108 |
user_repo=save_data.split('datasets/',1)[1].split('/raw',1)[0]
|
109 |
timestamp=str(datetime.datetime.now())
|
110 |
timename=timestamp.replace(" ","--").replace(":","-").replace(".","-")
|
@@ -139,7 +139,6 @@ def save_game(name,score,background_im,star_im,enemy_im):
|
|
139 |
print (e)
|
140 |
pass
|
141 |
|
142 |
-
#star_out=open(f"{uid}_star.png",'rb')
|
143 |
try:
|
144 |
api.upload_file(
|
145 |
path_or_fileobj=f"{uid}_star.png",
|
@@ -151,8 +150,6 @@ def save_game(name,score,background_im,star_im,enemy_im):
|
|
151 |
except Exception as e:
|
152 |
print (e)
|
153 |
pass
|
154 |
-
#enemy_out=open(enemy_im,'rb')
|
155 |
-
enemy_im.save('tmp_enemy.png')
|
156 |
|
157 |
try:
|
158 |
api.upload_file(
|
@@ -282,23 +279,20 @@ with gr.Blocks() as app:
|
|
282 |
game_name=gr.Textbox(label="Name for Game (optional)")
|
283 |
save_btn=gr.Button("Save")
|
284 |
message=gr.Textbox(label="Status",interactive=False)
|
285 |
-
|
286 |
-
|
287 |
score=gr.Textbox()
|
288 |
url_params=gr.Textbox()
|
289 |
-
with gr.Row():
|
290 |
text_input=gr.Textbox()
|
291 |
url_params = gr.JSON({}, visible=True, label="")
|
292 |
acc=gr.Textbox()
|
293 |
-
|
294 |
-
hid_sky=gr.Image(type='filepath')
|
295 |
-
hid_star=gr.Image(type='filepath')
|
296 |
-
hid_enemy=gr.Image(type='filepath')
|
297 |
|
298 |
def return_score(text):
|
299 |
return text
|
300 |
get_score.click(return_score,score,[score],_js=score_js)
|
301 |
-
save_btn.click(return_score,score,[score],_js=score_js).then(save_game,[game_name,score
|
302 |
update_game.click(game_fn,[out_sky_url,out_star_url,out_enemy_url],html_game)
|
303 |
btn_sky.click(sky_fn,prompt_sky,[out_im_sky,out_sky_url,hid_sky])
|
304 |
btn_star.click(star_fn,prompt_star,[out_im_star,out_star_url,hid_star])
|
|
|
104 |
out_url = f'https://omnibus-game-test.hf.space/file={out_file}'
|
105 |
return out,out_url,outrs
|
106 |
|
107 |
+
def save_game(name,score):
|
108 |
user_repo=save_data.split('datasets/',1)[1].split('/raw',1)[0]
|
109 |
timestamp=str(datetime.datetime.now())
|
110 |
timename=timestamp.replace(" ","--").replace(":","-").replace(".","-")
|
|
|
139 |
print (e)
|
140 |
pass
|
141 |
|
|
|
142 |
try:
|
143 |
api.upload_file(
|
144 |
path_or_fileobj=f"{uid}_star.png",
|
|
|
150 |
except Exception as e:
|
151 |
print (e)
|
152 |
pass
|
|
|
|
|
153 |
|
154 |
try:
|
155 |
api.upload_file(
|
|
|
279 |
game_name=gr.Textbox(label="Name for Game (optional)")
|
280 |
save_btn=gr.Button("Save")
|
281 |
message=gr.Textbox(label="Status",interactive=False)
|
282 |
+
with gr.Row(visible=False):
|
283 |
+
get_score=gr.Button("Get Score")
|
284 |
score=gr.Textbox()
|
285 |
url_params=gr.Textbox()
|
286 |
+
with gr.Row(visible=False):
|
287 |
text_input=gr.Textbox()
|
288 |
url_params = gr.JSON({}, visible=True, label="")
|
289 |
acc=gr.Textbox()
|
290 |
+
|
|
|
|
|
|
|
291 |
|
292 |
def return_score(text):
|
293 |
return text
|
294 |
get_score.click(return_score,score,[score],_js=score_js)
|
295 |
+
save_btn.click(return_score,score,[score],_js=score_js).then(save_game,[game_name,score],message)
|
296 |
update_game.click(game_fn,[out_sky_url,out_star_url,out_enemy_url],html_game)
|
297 |
btn_sky.click(sky_fn,prompt_sky,[out_im_sky,out_sky_url,hid_sky])
|
298 |
btn_star.click(star_fn,prompt_star,[out_im_star,out_star_url,hid_star])
|