generated from CMU-17313Q/NodeBB-f23
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from CMU-17313Q/creating_app_file
app.py created and tested successfully
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from flask import Flask, request | ||
|
||
from predict import predict | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/") | ||
def hello_world(): | ||
return "<p>Hello, World!</p>" | ||
|
||
@app.route("/predict", methods=["GET"]) | ||
def predict_student(): | ||
# Get parameters from the URL query string | ||
student_id = request.args.get("student_id") | ||
gender = request.args.get("gender") | ||
age = request.args.get("age") | ||
major = request.args.get("major") | ||
gpa = request.args.get("gpa") | ||
extra_curricular = request.args.get("extra_curricular") | ||
num_programming_languages = request.args.get("num_programming_languages") | ||
num_past_internships = request.args.get("num_past_internships") | ||
|
||
# Create a dictionary with the input parameters | ||
student = { | ||
"student_id": student_id, | ||
"gender": gender, | ||
"age": age, | ||
"major": major, | ||
"gpa": gpa, | ||
"extra_curricular": extra_curricular, | ||
"num_programming_languages": num_programming_languages, | ||
"num_past_internships": num_past_internships | ||
} | ||
|
||
# Call the predict function to get the prediction | ||
prediction_result = predict(student) | ||
# Convert 'int64' to 'int' for JSON serialization | ||
prediction_result['good_employee'] = int(prediction_result['good_employee']) | ||
|
||
return prediction_result |