Simon Strandgaard commited on
Commit
802e7b1
·
1 Parent(s): 1d7df48

can I spawn processes and use the file system inside huggingface spaces?

Browse files
Files changed (1) hide show
  1. app.py +16 -0
app.py CHANGED
@@ -1,5 +1,21 @@
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  """
5
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference
 
1
  import gradio as gr
2
  from huggingface_hub import InferenceClient
3
+ import subprocess
4
+
5
+ # Spawn a child process that lists files in the current directory.
6
+ result = subprocess.run(["pwd"], capture_output=True, text=True)
7
+ print("Child process output:")
8
+ print(result.stdout)
9
+
10
+ # Write a file
11
+ with open("output.txt", "w") as f:
12
+ f.write("Hello from Hugging Face Spaces!")
13
+
14
+ # Read the file back
15
+ with open("output.txt", "r") as f:
16
+ content = f.read()
17
+ print("File content:", content)
18
+
19
 
20
  """
21
  For more information on `huggingface_hub` Inference API support, please check the docs: https://huggingface.co/docs/huggingface_hub/v0.22.2/en/guides/inference