WebashalarForML commited on
Commit
9a45dad
·
verified ·
1 Parent(s): 9830733

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -10
app.py CHANGED
@@ -9,21 +9,15 @@ from utils.model import train_model
9
  import zipfile
10
 
11
 
12
-
13
-
14
  app = Flask(__name__)
15
  app.secret_key = 'your_secret_key'
16
-
17
-
18
  os.umask(0o000)
19
 
20
-
21
-
22
  # Folder paths
23
- app.config['UPLOAD_FOLDER'] = '/app/uploads'
24
- app.config['JSON_FOLDER'] = '/app/JSON'
25
- app.config['DATA_FOLDER'] = '/app/data'
26
- app.config['MODELS_FOLDER'] = '/app/Models'
27
 
28
  # Creating Folders if not exists
29
  os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
@@ -31,6 +25,24 @@ os.makedirs(app.config['JSON_FOLDER'], exist_ok=True)
31
  os.makedirs(app.config['DATA_FOLDER'], exist_ok=True)
32
  os.makedirs(app.config['MODELS_FOLDER'], exist_ok=True)
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  # Allowed file extensions
35
  ALLOWED_EXTENSIONS = {'pdf', 'docx', 'rsf', 'odt', 'png', 'jpg', 'jpeg', 'json'}
36
 
@@ -169,5 +181,12 @@ def download_latest_model():
169
  flash(f"Error while downloading the model: {str(e)}", 'error')
170
  return redirect(request.referrer)
171
 
 
 
 
 
 
 
 
172
  if __name__ == '__main__':
173
  app.run(debug=True)
 
9
  import zipfile
10
 
11
 
 
 
12
  app = Flask(__name__)
13
  app.secret_key = 'your_secret_key'
 
 
14
  os.umask(0o000)
15
 
 
 
16
  # Folder paths
17
+ app.config['UPLOAD_FOLDER'] = 'uploads/'
18
+ app.config['JSON_FOLDER'] = 'JSON/'
19
+ app.config['DATA_FOLDER'] = 'data/'
20
+ app.config['MODELS_FOLDER'] = 'Models/'
21
 
22
  # Creating Folders if not exists
23
  os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
 
25
  os.makedirs(app.config['DATA_FOLDER'], exist_ok=True)
26
  os.makedirs(app.config['MODELS_FOLDER'], exist_ok=True)
27
 
28
+ # Verify and check once again if the folders are created or not
29
+ if not os.path.exists(app.config['UPLOAD_FOLDER']):
30
+ os.makedirs(app.config['UPLOAD_FOLDER'])
31
+
32
+ if not os.path.exists(app.config['JSON_FOLDER']):
33
+ os.makedirs(app.config['JSON_FOLDER'])
34
+
35
+ if not os.path.exists(app.config['DATA_FOLDER']):
36
+ os.makedirs(app.config['DATA_FOLDER'])
37
+
38
+ if not os.path.exists(app.config['MODELS_FOLDER']):
39
+ os.makedirs(app.config['MODELS_FOLDER'])
40
+
41
+ # Create the empty file
42
+ file_path = os.path.join(app.config['DATA_FOLDER'], 'resume_text.txt')
43
+ with open(file_path, 'w') as file:
44
+ pass
45
+
46
  # Allowed file extensions
47
  ALLOWED_EXTENSIONS = {'pdf', 'docx', 'rsf', 'odt', 'png', 'jpg', 'jpeg', 'json'}
48
 
 
181
  flash(f"Error while downloading the model: {str(e)}", 'error')
182
  return redirect(request.referrer)
183
 
184
+ # Route to serve uploaded files
185
+ '''
186
+ @app.route('/uploads/<filename>')
187
+ def uploaded_file(filename):
188
+ return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
189
+ '''
190
+
191
  if __name__ == '__main__':
192
  app.run(debug=True)