darpanaswal commited on
Commit
a181011
·
verified ·
1 Parent(s): 0923429

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -1,14 +1,15 @@
1
  from flask import Flask, render_template, request, send_file
2
- import tempfile
3
- import os
4
  from run import predict_and_show
5
 
6
  app = Flask("Ogs")
7
 
 
8
  @app.route('/')
9
  def index():
10
  return render_template('index.html')
11
 
 
12
  @app.route('/upload', methods=['POST'])
13
  def upload():
14
  if 'file' not in request.files:
@@ -19,17 +20,13 @@ def upload():
19
  if file.filename == '':
20
  return "No selected file"
21
 
22
- # Use a temporary file to avoid permission issues
23
- with tempfile.NamedTemporaryFile(delete=False) as temp_file:
24
- file.save(temp_file.name)
25
- # Ensure the file is saved before processing
26
- temp_file.flush()
27
- # Process the image
28
- predict_and_show(temp_file.name)
29
- # Clean up if necessary
30
- os.unlink(temp_file.name)
31
 
32
  return send_file("attendance.csv", as_attachment=True)
33
 
 
34
  if __name__ == '__main__':
35
  app.run(debug=True)
 
1
  from flask import Flask, render_template, request, send_file
2
+ # Import your attendance model and processing functions
 
3
  from run import predict_and_show
4
 
5
  app = Flask("Ogs")
6
 
7
+
8
  @app.route('/')
9
  def index():
10
  return render_template('index.html')
11
 
12
+
13
  @app.route('/upload', methods=['POST'])
14
  def upload():
15
  if 'file' not in request.files:
 
20
  if file.filename == '':
21
  return "No selected file"
22
 
23
+ file.save("image.jpeg")
24
+
25
+ # Process the image using your attendance model
26
+ predict_and_show("image.jpeg")
 
 
 
 
 
27
 
28
  return send_file("attendance.csv", as_attachment=True)
29
 
30
+
31
  if __name__ == '__main__':
32
  app.run(debug=True)