-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
34 lines (25 loc) · 916 Bytes
/
main.py
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
31
32
33
34
from flask import Flask, request, jsonify
from flask_basicauth import BasicAuth
# import pandas as pd
import numpy as np
from predict_model import prediction
import os
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
app = Flask(__name__)
app.config['BASIC_AUTH_USERNAME'] = os.getenv("BASIC_AUTH_USERNAME")
app.config['BASIC_AUTH_PASSWORD'] = os.getenv("BASIC_AUTH_PASSWORD")
basic_auth = BasicAuth(app)
columns = ["Gender", "Married", "ApplicantIncome", "LoanAmount", "Credit_History"]
@app.route("/score", methods=['POST'])
@basic_auth.required
def get_score():
data = request.json
result = prediction(data["Gender"], data["Married"], data["ApplicantIncome"], data["LoanAmount"], data["Credit_History"])
return result
# Rota padrão
@app.route('/')
def home():
return 'API de Consulta de Crédito'
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")