-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (22 loc) · 980 Bytes
/
Copy pathapp.py
File metadata and controls
30 lines (22 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from flask import Flask, request, jsonify, render_template
# Initialize Flask app
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html') # Serve the HTML file
@app.route('/predict', methods=['POST'])
def predict():
data = request.get_json(force=True)
# Input validation
try:
study_hours = float(data['study_hours'])
attendance = float(data['attendance'])
previous_grades = float(data['previous_grades'])
# Mock prediction logic
# For example, let's say predicted marks = (study_hours * 10) + (attendance * 0.5) + (previous_grades * 0.5)
predicted_marks = (study_hours * 10) + (attendance * 0.5) + (previous_grades * 0.5)
except (KeyError, ValueError):
return jsonify({'error': 'Invalid input data. Please provide valid numbers.'}), 400
return jsonify({'predicted_marks': predicted_marks})
if __name__ == '__main__':
app.run(debug=True)