rrg92 commited on
Commit
b17787d
1 Parent(s): 828a901

Typos and code enhance

Browse files
Files changed (1) hide show
  1. app.py +24 -3
app.py CHANGED
@@ -6,9 +6,30 @@ def GetFile():
6
 
7
 
8
  with gr.Blocks() as demo:
9
- gr.Markdown("This space shows a problem with Gradio API when used inside Hugging Face Space.")
10
- gr.Markdown("You can you any favorite http client to reproduce that. Use sample code bellow as reference")
11
- gr.Markdown("*Problem*: File url returned by Gradio API is incorrect")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  btn = gr.Button("Click that button to start!")
14
  fileResult = gr.File()
 
6
 
7
 
8
  with gr.Blocks() as demo:
9
+ gr.Markdown("""
10
+ This space demonstrates an issue with the Gradio API related to file donwloads.
11
+ You can use any preferred HTTP client to reproduce the issue. Refer to the sample code below.
12
+ **Problem**: The file URL returned by the Gradio API is incorrect.
13
+
14
+
15
+ this a sample curl code:
16
+ ```bash
17
+ space="https://rrg92-gradioapibug.hf.space"; curl -X POST "$space/call/GetFile" -s -H "Content-Type: application/json" -d '{"data":[]}' | awk -F'"' '{print $4}' | { read event; curl -s "$space/call/GetFile/$event" | grep -oEi '"url": ".*?"' | awk -F'"' '{print $4}' ; }
18
+ ```
19
+
20
+
21
+ this is same version, but can run in Powershell
22
+ ```posh
23
+ $space = "https://rrg92-gradioapibug.hf.space"; iwr -met POST -Uri "$space/call/GetFile" -Body '{"data":[]}' -ContentType "application/json" | ConvertFrom-Json | %{ $_.event_id } | %{ iwr -uri "$space/call/GetFile/$_" } | %{$null=$_.content -match "data: (.+)"; $matches[1] } | ConvertFrom-Json | %{ $_.url}
24
+ ```
25
+
26
+ The sample code is supposed to output a URL path to a file generated by the Gradio API. However, if you try to access the link, it returns a "not found" error.
27
+ The issue arises because the 'url' field returned by the API is incorrect. It should follow the format: `HOST/FILE=PATH`, but it returns a different path.
28
+
29
+ In my tests, I couldn't determine the exact path, but for example, it returns something like `HOST/c/file=PATH`.
30
+ In other cases, I've seen it return paths such as `HOST/call/ApiName/file=PATH`.
31
+ """)
32
+
33
 
34
  btn = gr.Button("Click that button to start!")
35
  fileResult = gr.File()