saurabh091 commited on
Commit
a5a2cc8
·
verified ·
1 Parent(s): a0ed748

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -7,19 +7,13 @@ import os
7
  import pandas as pd
8
  import shutil
9
 
10
- folder_path = "/tmp/Upload" # Use /tmp instead of root
11
 
12
- # Ensure the folder structure exists
13
- if not os.path.exists(folder_path):
14
- os.makedirs(folder_path)
15
-
16
- print(f"Directory created at {folder_path}")
17
 
18
  def clr_static():
19
  """
20
  for removing the static folder (for memoery saving in web)
21
  """
22
- dir = 'static'
23
  try:
24
  shutil.rmtree(dir)
25
  print("Cleared Static")
@@ -30,7 +24,7 @@ def clr_old_upload():
30
  """
31
  for removing the old images uploaded file (for memoery saving in web)
32
  """
33
- dir = 'UPLOAD_FOLDER'
34
  try:
35
  shutil.rmtree(dir)
36
  print("Cleared UPLOAD_FOLDER")
@@ -41,7 +35,7 @@ def clr_old_upload():
41
  #making dir to save the generated csv file
42
  def mk_csv_folder():
43
  try:
44
- os.mkdir("static/CSV_File")
45
  print("made csv_folder")
46
  except:
47
  pass
@@ -49,7 +43,7 @@ def mk_csv_folder():
49
  #Creating UPLOAD_FOLDER dir to save the Uploaded file
50
  def mk_uploaded_folder():
51
  try:
52
- os.mkdir("UPLOAD_FOLDER")
53
  print("made UPLOAD_FOLDER")
54
  except:
55
  pass
@@ -57,7 +51,7 @@ def mk_uploaded_folder():
57
  #Creating static dir to save the generated file
58
  def mk_static_folder():
59
  try:
60
- os.mkdir("static")
61
  print("made static folder")
62
  except:
63
  pass
@@ -110,11 +104,11 @@ def Use_yolo(img_path):
110
 
111
  sub = pd.DataFrame(all_data)
112
 
113
- sub.to_csv("static/CSV_File/WBC_File.csv", index=False)
114
 
115
 
116
- app = Flask(__name__)
117
- app.config['UPLOAD_FOLDER'] = 'UPLOAD_FOLDER'
118
 
119
  @app.route('/')
120
  def home():
 
7
  import pandas as pd
8
  import shutil
9
 
 
10
 
 
 
 
 
 
11
 
12
  def clr_static():
13
  """
14
  for removing the static folder (for memoery saving in web)
15
  """
16
+ dir = '/tmp/static'
17
  try:
18
  shutil.rmtree(dir)
19
  print("Cleared Static")
 
24
  """
25
  for removing the old images uploaded file (for memoery saving in web)
26
  """
27
+ dir = '/tmp/UPLOAD_FOLDER'
28
  try:
29
  shutil.rmtree(dir)
30
  print("Cleared UPLOAD_FOLDER")
 
35
  #making dir to save the generated csv file
36
  def mk_csv_folder():
37
  try:
38
+ os.mkdir("/tmp/static/CSV_File")
39
  print("made csv_folder")
40
  except:
41
  pass
 
43
  #Creating UPLOAD_FOLDER dir to save the Uploaded file
44
  def mk_uploaded_folder():
45
  try:
46
+ os.mkdir("/tmp/UPLOAD_FOLDER")
47
  print("made UPLOAD_FOLDER")
48
  except:
49
  pass
 
51
  #Creating static dir to save the generated file
52
  def mk_static_folder():
53
  try:
54
+ os.mkdir("/tmp/static")
55
  print("made static folder")
56
  except:
57
  pass
 
104
 
105
  sub = pd.DataFrame(all_data)
106
 
107
+ sub.to_csv("/tmp/static/CSV_File/WBC_File.csv", index=False)
108
 
109
 
110
+ app = Flask(__name__, static_folder="/tmp")
111
+ app.config['UPLOAD_FOLDER'] = '/tmp/UPLOAD_FOLDER'
112
 
113
  @app.route('/')
114
  def home():