panda1835 commited on
Commit
de23a48
β€’
1 Parent(s): 56734dd

Upload 2 files

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py CHANGED
@@ -2,9 +2,15 @@ import gradio as gr
2
  import pypokedex
3
  import json
4
  import utils
 
 
 
5
 
6
  streaks = utils.get_streak()
7
  pokemons = utils.get_pokemon()
 
 
 
8
 
9
  def new_streak(intensity):
10
  global pokemons
@@ -23,11 +29,22 @@ def new_streak(intensity):
23
  # pokemon_exps.append(info)
24
  # return pokemon_exps
25
 
 
 
 
 
 
 
 
 
 
 
26
  with gr.Blocks() as demo:
27
 
28
  gr.Markdown('<h1 style="text-align: center;">PokeVerse</h1>')
29
  reward_md = gr.Markdown()
30
  winning_btn = gr.Button("Are you winning today? πŸ’ͺ")
 
31
  intensity = gr.Slider(0, 3, step=1, label="Intensity")
32
  streak_md = gr.Markdown(f"{streaks} streak days")
33
  streakboard = gr.Markdown('## ' + 'βœ… ' * streaks)
@@ -48,5 +65,6 @@ with gr.Blocks() as demo:
48
 
49
 
50
  winning_btn.click(new_streak, inputs=[intensity], outputs=[streak_md, streakboard, reward_md])
 
51
  # streak_md.change(update_pokemon_gallery, outputs=pokemon_exps)
52
  demo.launch()
 
2
  import pypokedex
3
  import json
4
  import utils
5
+ import datetime
6
+ from huggingface_hub import login, HfApi
7
+ import os
8
 
9
  streaks = utils.get_streak()
10
  pokemons = utils.get_pokemon()
11
+ hf_token = os.environ["HF_TOKEN"]
12
+ login(hf_token)
13
+ hfapi = HfApi()
14
 
15
  def new_streak(intensity):
16
  global pokemons
 
29
  # pokemon_exps.append(info)
30
  # return pokemon_exps
31
 
32
+ def restart():
33
+ with open('dummy.txt', 'w') as f:
34
+ f.write(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
35
+ hfapi.upload_file(
36
+ path_or_fileobj="dummy.txt",
37
+ path_in_repo="dummy.txt",
38
+ repo_id="panda1835/pokemon-habit",
39
+ repo_type="space",
40
+ )
41
+
42
  with gr.Blocks() as demo:
43
 
44
  gr.Markdown('<h1 style="text-align: center;">PokeVerse</h1>')
45
  reward_md = gr.Markdown()
46
  winning_btn = gr.Button("Are you winning today? πŸ’ͺ")
47
+ restart_btn = gr.Button("Restart πŸ€")
48
  intensity = gr.Slider(0, 3, step=1, label="Intensity")
49
  streak_md = gr.Markdown(f"{streaks} streak days")
50
  streakboard = gr.Markdown('## ' + 'βœ… ' * streaks)
 
65
 
66
 
67
  winning_btn.click(new_streak, inputs=[intensity], outputs=[streak_md, streakboard, reward_md])
68
+ restart_btn.click(restart, None, None)
69
  # streak_md.change(update_pokemon_gallery, outputs=pokemon_exps)
70
  demo.launch()