Commit 564e9b76 authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

some changes

parent 61a81548
...@@ -68,22 +68,27 @@ def getColorActivitiesResult(): ...@@ -68,22 +68,27 @@ def getColorActivitiesResult():
@app.route("/predict", methods=["POST"]) @app.route("/predict", methods=["POST"])
def predict(): def predict():
data = request.get_json() try:
print((f"{data}")) data = request.get_json()
fileitem = data['uri'] fileitem = data['uri']
# if fileitem.filename: colorName = data['colorNmae']
# # strip the leading path from the file name # print((f"{colorName}"))
fn = os.path.basename(fileitem)
# # if fileitem.filename:
# # open read and write the file into the server # # strip the leading path from the file name
open(fn, 'wb').write(fileitem.file.read()) fn = os.path.basename(fileitem)
#
resp = make_response(request.get_json()) # # open read and write the file into the server
resp.headers['Access-Control-Allow-Origin'] = '*' # open(fn, 'wb').write(fileitem.file.read())
resp.headers['Content-Type'] = 'application/json'
return resp resp = make_response(request.get_json())
resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Content-Type'] = 'application/json'
return resp
except ValueError:
print(ValueError)
# get audio file and save it # get audio file and save it
# audio_file = request.files["file"] # audio_file = request.files["file"]
......
...@@ -94,25 +94,12 @@ export default function Blue(color) { ...@@ -94,25 +94,12 @@ export default function Blue(color) {
const formData = new FormData(); const formData = new FormData();
var obj = { var obj = {
uri: `file://${audioFile}`, uri: `file:${audioFile}`,
type: 'audio/wav', type: 'audio/wav',
name: 'color.wav', name: 'color.wav',
colorNmae: backColor colorNmae: backColor
} }
// formData.append(
// 'file',
// {
// uri: `file://${audioFile}`,
// type: 'audio/wav',
// name: 'color.wav',
// }
// );
// formData.append(
// 'name', backColor
// );
var data = JSON.stringify(obj) var data = JSON.stringify(obj)
console.log(data); console.log(data);
......
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