diff --git a/requirements.txt b/requirements.txt index 08c45b7..13d469d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,5 @@ scikit-learn==1.0.2 scipy==1.8.0 six==1.16.0 threadpoolctl==3.1.0 +Flask==3.0.1 +flask_cors==5.0.0 diff --git a/src/__pycache__/api.cpython-310.pyc b/src/__pycache__/api.cpython-310.pyc new file mode 100644 index 0000000..afcbcfb Binary files /dev/null and b/src/__pycache__/api.cpython-310.pyc differ diff --git a/src/api.py b/src/api.py new file mode 100644 index 0000000..a600480 --- /dev/null +++ b/src/api.py @@ -0,0 +1,27 @@ +import os + +from flask import Flask, Response +from flask_cors import CORS +import pandas as pd + +app = Flask(__name__) + +CORS(app) + + +training_data = pd.read_csv(os.path.join("data", "auto-mpg.csv")) + + +@app.route("/", methods=["GET"]) +def index(): + return {"hello": "world"} + + +@app.route("/hello_world", methods=["GET"]) +def hello_world(): + return "
Hello World!
" + + +@app.route("/training_data", methods=["GET"]) +def get_training_data(): + return Response(training_data.to_json(), mimetype="application/json") diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..f00b2be --- /dev/null +++ b/wsgi.py @@ -0,0 +1,5 @@ +from src.api import app + + +if __name__ == "__main__": + app.run(debug=True)