Omnibus commited on
Commit
a3d7998
1 Parent(s): 7745788

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -26,22 +26,7 @@ platform = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/
26
  star = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/star.png'
27
  bomb = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/bomb.png'
28
  dude = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/dude.png'
29
- def predict(text, url_params):
30
- load_game=url_params.get('game')
31
- print (load_game)
32
- if load_game != None:
33
- try:
34
- r = requests.get(f'{save_data}games/{load_game}.omnigame')
35
- lod = json.loads(r.text)
36
- #out_lod.append(lod)
37
- print (lod)
38
- except:
39
- print("cannot load game")
40
- pass
41
-
42
- else:
43
- pass
44
- return ["" + text + "", 'out']
45
  get_window_url_params = """
46
  function(text_input, url_params) {
47
  console.log(text_input, url_params);
@@ -234,7 +219,25 @@ def save_game(name,score,background_img,star_img,enemy_img,platform_img,dude_img
234
  print (e)
235
  return f'Error Saving Game: {e}'
236
  return f"Game Saved\nURL: {game_url}"
237
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
 
239
  score_js="""
240
 
@@ -290,7 +293,7 @@ with gr.Blocks() as app:
290
  btn_sky.click(sky_fn,prompt_sky,[out_im_sky,out_sky_url])
291
  btn_star.click(star_fn,prompt_star,[out_im_star,out_star_url])
292
  btn_enemy.click(enemy_fn,prompt_enemy,[out_im_enemy,out_enemy_url])
293
- app.load(predict,[text_input,url_params],[text_input,acc], _js=get_window_url_params)
294
 
295
  #app.load(sky_fn,prompt_sky,[out_im_sky,out_sky_url]).then(game_fn,[out_sky_url],html_game)
296
  app.queue(concurrency_count=10).launch()
 
26
  star = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/star.png'
27
  bomb = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/bomb.png'
28
  dude = 'https://huggingface.co/spaces/Omnibus/game-test/resolve/main/assets/dude.png'
29
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  get_window_url_params = """
31
  function(text_input, url_params) {
32
  console.log(text_input, url_params);
 
219
  print (e)
220
  return f'Error Saving Game: {e}'
221
  return f"Game Saved\nURL: {game_url}"
222
+ def predict(text, url_params):
223
+ load_game=url_params.get('game')
224
+ print (load_game)
225
+ if load_game != None:
226
+ try:
227
+ r = requests.get(f'{save_data}games/{load_game}.omnigame')
228
+ lod = json.loads(r.text)
229
+ game_html=game_fn(lod['background_url'],lod['star_url'],lod['enemy_url'])
230
+ #out_lod.append(lod)
231
+ print (lod)
232
+ print (game_html)
233
+ return "" + text + "",game_html
234
+ except:
235
+ print("cannot load game")
236
+ pass
237
+
238
+ else:
239
+ pass
240
+ return ["" + text + "", ""]
241
 
242
  score_js="""
243
 
 
293
  btn_sky.click(sky_fn,prompt_sky,[out_im_sky,out_sky_url])
294
  btn_star.click(star_fn,prompt_star,[out_im_star,out_star_url])
295
  btn_enemy.click(enemy_fn,prompt_enemy,[out_im_enemy,out_enemy_url])
296
+ app.load(predict,[text_input,url_params],[text_input,html_game], _js=get_window_url_params)
297
 
298
  #app.load(sky_fn,prompt_sky,[out_im_sky,out_sky_url]).then(game_fn,[out_sky_url],html_game)
299
  app.queue(concurrency_count=10).launch()