Docfile commited on
Commit
414ae53
·
verified ·
1 Parent(s): 607392d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -9,8 +9,7 @@ import os
9
  import time
10
  from datetime import datetime
11
 
12
-
13
- app = Flask(__name__, template_folder='templates')
14
 
15
  # Configuration globale
16
  config = {
@@ -228,12 +227,19 @@ def view_accounts():
228
  )
229
 
230
  if __name__ == '__main__':
231
- # Créer le dossier templates s'il n'existe pas
232
- if not os.path.exists('templates'):
233
- os.makedirs('templates')
234
-
235
- # Créer les templates HTML
236
- with open('templates/index.html', 'w') as f:
 
 
 
 
 
 
 
237
  f.write('''
238
  <!DOCTYPE html>
239
  <html lang="fr">
@@ -429,8 +435,8 @@ if __name__ == '__main__':
429
  </body>
430
  </html>
431
  ''')
432
-
433
- with open('templates/accounts.html', 'w') as f:
434
  f.write('''
435
  <!DOCTYPE html>
436
  <html lang="fr">
@@ -533,5 +539,5 @@ if __name__ == '__main__':
533
  </body>
534
  </html>
535
  ''')
536
-
537
  app.run(debug=True)
 
9
  import time
10
  from datetime import datetime
11
 
12
+ app = Flask(__name__)
 
13
 
14
  # Configuration globale
15
  config = {
 
227
  )
228
 
229
  if __name__ == '__main__':
230
+ # Get the directory of the current script
231
+ current_dir = os.path.dirname(os.path.abspath(__file__))
232
+
233
+ # Create the templates directory if it doesn't exist
234
+ templates_dir = os.path.join(current_dir, 'templates')
235
+ if not os.path.exists(templates_dir):
236
+ os.makedirs(templates_dir)
237
+
238
+ # Create the HTML template files using absolute paths
239
+ index_html_path = os.path.join(templates_dir, 'index.html')
240
+ accounts_html_path = os.path.join(templates_dir, 'accounts.html')
241
+
242
+ with open(index_html_path, 'w') as f:
243
  f.write('''
244
  <!DOCTYPE html>
245
  <html lang="fr">
 
435
  </body>
436
  </html>
437
  ''')
438
+
439
+ with open(accounts_html_path, 'w') as f:
440
  f.write('''
441
  <!DOCTYPE html>
442
  <html lang="fr">
 
539
  </body>
540
  </html>
541
  ''')
542
+
543
  app.run(debug=True)