darpanaswal's picture
Update app.py (#1)
2ffa538 verified
from flask import Flask, render_template, request, send_file, make_response
# Import your attendance model and processing functions
from run import predict_and_show
import pandas as pd
app = Flask("Ogs")
@app.route('/')
def index():
return render_template('index.html')
@app.route('/upload', methods=['POST'])
def upload():
if 'file' not in request.files:
return "No file part"
file = request.files['file']
if file.filename == '':
return "No selected file"
# Process the image using your attendance model
data = predict_and_show(file)
html_content = "<html><body><h1>Attendance Report</h1><ul>"
for item in data:
html_content += f"<li>{item}</li>"
html_content += "</ul></body></html>"
# Create a response object with the generated HTML
response = make_response(html_content)
response.headers['Content-Type'] = 'text/html'
return response
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=7860)