Omnibus commited on
Commit
152548d
·
verified ·
1 Parent(s): 81569db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -4
app.py CHANGED
@@ -1,5 +1,28 @@
1
  import os
2
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  def get_map(inp):
4
  if inp == os.environ.get("PASS"):
5
  print("downloading")
@@ -8,12 +31,11 @@ def get_map(inp):
8
  print("done")
9
  out = os.path.abspath("quebec-latest.osm.pbf")
10
  print (out)
11
- return gr.update()
 
12
  with gr.Blocks() as app:
13
  with gr.Row():
14
  inp_pass=gr.Textbox()
15
  btn=gr.Button()
16
-
17
- fs = gr.FileExplorer()
18
- btn.click(get_map,inp_pass,fs)
19
  app.launch()
 
1
  import os
2
  import gradio as gr
3
+ from huggingface_hub import HfApi
4
+
5
+ reponame="Omnibus/osm"
6
+ save_data=f'https://huggingface.co/datasets/{reponame}/raw/main/'
7
+ token_self = os.environ['HF_TOKEN']
8
+ api=HfApi(token=token_self)
9
+
10
+
11
+ def save_file_data(inp):
12
+ try:
13
+ file_obj=inp
14
+ api.upload_file(
15
+ path_or_fileobj=inp,
16
+ path_in_repo=inp,
17
+ repo_id=reponame,
18
+ #repo_id=save_data.split('datasets/',1)[1].split('/raw',1)[0],
19
+ token=token_self,
20
+ repo_type="dataset",
21
+ )
22
+ print("Done")
23
+ except Exception as e:
24
+ print(e)
25
+
26
  def get_map(inp):
27
  if inp == os.environ.get("PASS"):
28
  print("downloading")
 
31
  print("done")
32
  out = os.path.abspath("quebec-latest.osm.pbf")
33
  print (out)
34
+ save_file_data("quebec-latest.osm.pbf")
35
+ print("saved")
36
  with gr.Blocks() as app:
37
  with gr.Row():
38
  inp_pass=gr.Textbox()
39
  btn=gr.Button()
40
+ btn.click(get_map,inp_pass,None)
 
 
41
  app.launch()