Teacher Promotion Flask API
teacher-promotion-flask-api
Flask API for teacher promotion. Due to confidentiality agreements, I am unable to disclose the data used for training the model or the three promotion parameters labeled as 1, 2 and 3. However, you are welcome to utilize the API or customize it as needed. Thank you.
Install Requirements
pip install -r requirements.txtSetup
open the terminal
clone the repository
bash git clone https://github.com/saeedahmadicp/teacher-promotion-flask-api.gitchange the directory
cd teacher-promotion-flask-apiexecute the below commands
bash pip3 install pipenvbash pipenv installbash pipenv shellinstall the requirements
bash pip install -r requirements.txtexecute the following commands
bash set FLASK_APP=main.pybash set FLASK_ENV=developmentbash flask runIf you are using Linux or Mac, use
exportinstead ofsetin the above commands
Source Code: main.py
from flask import Flask, render_template, request, redirect
from load_process_prediction import label_encoder, process_and_predict
#Declaring the flask object
app = Flask(__name__)
#defining the home route
@app.route('/')
def home():
return render_template('index.html')
#defing the result route
@app.route('/result', methods=['GET', 'POST'])
def result():
if request.method == 'POST': #use args if using get method
firstName = request.form['fname']
lastName = request.form['lname']
age = request.form['age']
experience = request.form['experience']
grade = request.form['grade']
lastPromotion = request.form['lpromotion']
promo1 = request.form['promo1']
promo2 = request.form['promo2']
promo3 = request.form['promo3']
data = [age, experience, grade, lastPromotion, label_encoder(promo1), label_encoder(promo2), label_encoder(promo3)]
prediction = process_and_predict(data)
#redirecting the user to the page
return render_template('result.html', firstName=firstName, lastName=lastName, prediction=prediction)
else:
return redirect('/')