ysharma HF Staff commited on
Commit
0a9f5a4
·
verified ·
1 Parent(s): 1f71a96

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -19,27 +19,30 @@ def create_local():
19
  f.write(text_string + '\n')
20
 
21
 
22
- def move():
23
  # Get the path of the system's temporary directory
24
  temp_directory = tempfile.gettempdir()
25
 
26
  # Specify the path of the file you want to move
27
- file_path = 'temp_dir/random_file1.txt'
28
-
 
 
 
29
  # Construct the new path in the temporary directory with the same filename
30
  new_path = os.path.join(temp_directory, os.path.basename(file_path))
31
 
32
  print(f'new_path - {new_path}')
33
 
34
  # Move the file
35
- shutil.move(file_path, new_path)
36
 
37
  print(f"Moved the file to: {new_path}")
38
 
39
 
40
  # Assuming 'my_directory' is a directory in the current working directory
41
- #directory_name = 'temp_dir'
42
- #absolute_path1 = os.path.abspath(directory_name)
43
  #print(f"The absolute path of '{directory_name}' is: {absolute_path1}")
44
  #/home/user/app/temp_dir
45
 
@@ -98,6 +101,6 @@ with gr.Blocks(delete_cache=(5,10),
98
 
99
  btn.click(create,inputs=[],outputs=[out, inp])
100
  btn1.click(create_local,inputs=[],outputs=[])
101
- btn2.click(move,inputs=[],outputs=[])
102
 
103
  demo.launch(debug=False)
 
19
  f.write(text_string + '\n')
20
 
21
 
22
+ def movefiles():
23
  # Get the path of the system's temporary directory
24
  temp_directory = tempfile.gettempdir()
25
 
26
  # Specify the path of the file you want to move
27
+ directory_name = 'temp_dir'
28
+ absolute_path = os.path.abspath(directory_name)
29
+ file_path = 'random_file1.txt'
30
+ old_path = os.path.join(absolute_path, os.path.basename(file_path))
31
+
32
  # Construct the new path in the temporary directory with the same filename
33
  new_path = os.path.join(temp_directory, os.path.basename(file_path))
34
 
35
  print(f'new_path - {new_path}')
36
 
37
  # Move the file
38
+ shutil.move(old_path, new_path)
39
 
40
  print(f"Moved the file to: {new_path}")
41
 
42
 
43
  # Assuming 'my_directory' is a directory in the current working directory
44
+ directory_name = 'temp_dir'
45
+ absolute_path1 = os.path.abspath(directory_name)
46
  #print(f"The absolute path of '{directory_name}' is: {absolute_path1}")
47
  #/home/user/app/temp_dir
48
 
 
101
 
102
  btn.click(create,inputs=[],outputs=[out, inp])
103
  btn1.click(create_local,inputs=[],outputs=[])
104
+ btn2.click(movefiles,inputs=[],outputs=[])
105
 
106
  demo.launch(debug=False)