Commit f6bb20e9 authored by IT20161538's avatar IT20161538

New commit

parent 950ebf2b
This diff is collapsed.
from flask import Flask, request, jsonify
import pandas as pd
from Decision_Tree.Decision_Tree import sideEffectTreatments
import numpy as np
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
def convert_ndarray_to_list(data_dict):
converted_dict = {}
for key, value in data_dict.items():
if isinstance(value, np.ndarray):
converted_dict[key] = value.tolist()
else:
converted_dict[key] = value
return converted_dict
@app.route('/predict', methods=['OPTIONS', 'GET', 'POST'])
def predict():
if request.method == 'OPTIONS':
# Handle CORS preflight request here
return '', 200
elif request.method == 'POST':
try:
# Extract data from the JSON request
data = request.get_json()
# Convert the JSON data to a pandas DataFrame
new_person_data = pd.DataFrame(data)
print(new_person_data)
# Call the test function to make predictions
predictions = sideEffectTreatments(new_person_data)
# Convert NumPy ndarray predictions to a serializable format
converted_predictions = convert_ndarray_to_list(predictions)
return jsonify(converted_predictions)
except Exception as e:
return jsonify({'error': str(e)})
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5500)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-router-dom": "^6.10.0", "react-router-dom": "^6.10.0",
...@@ -5065,6 +5066,29 @@ ...@@ -5065,6 +5066,29 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/axios": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz",
"integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==",
"dependencies": {
"follow-redirects": "^1.15.0",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/axobject-query": { "node_modules/axobject-query": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz",
...@@ -14030,6 +14054,11 @@ ...@@ -14030,6 +14054,11 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": { "node_modules/psl": {
"version": "1.9.0", "version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
......
src/assets/6.jpg

73.6 KB | W: | H:

src/assets/6.jpg

6.53 KB | W: | H:

src/assets/6.jpg
src/assets/6.jpg
src/assets/6.jpg
src/assets/6.jpg
  • 2-up
  • Swipe
  • Onion skin
...@@ -16,8 +16,9 @@ ...@@ -16,8 +16,9 @@
border-radius:6px; border-radius:6px;
box-shadow:0 0 8px #696969; box-shadow:0 0 8px #696969;
padding-block: 10px; padding-block: 10px;
width: 45vw; width: 47vw;
margin-top: 80px; margin-top: 80px;
margin-left: 80px;
} }
.title{ .title{
...@@ -26,7 +27,7 @@ ...@@ -26,7 +27,7 @@
.form{ .form{
width: 35vw; width: 35vw;
height: 750px; height: 950px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: start; justify-content: start;
...@@ -71,9 +72,7 @@ input{ ...@@ -71,9 +72,7 @@ input{
} }
.input-group1{ .input-group1{
display: flex;
flex-direction: row; align-items: left;
gap: 10px;
align-items: center; }
padding: 5px;
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment