Skip to content

Commit

Permalink
Merge pull request #51 from CMU-17313Q/creating_app_file
Browse files Browse the repository at this point in the history
app.py created and tested successfully
  • Loading branch information
mrahmatu authored Nov 9, 2023
2 parents 0d9c710 + de07e9c commit 02b15b6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Binary file added career-model/__pycache__/app.cpython-39.pyc
Binary file not shown.
Binary file added career-model/__pycache__/predict.cpython-39.pyc
Binary file not shown.
40 changes: 40 additions & 0 deletions career-model/app.py
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

0 comments on commit 02b15b6

Please sign in to comment.