Issue
I try return the result of function np.correlate, using flask and numpy
from flask import Flask
import numpy as np
app = Flask(__name__)
@app.route("/")
def corelation():
# 1 2 3 8 9 7 3 12 65 45 26 33
firstArray = np.loadtxt("C:\\Users\\user\\source\\repos\\CorelationApplication\\firstfile.txt")
# 43 32 23 45 65 99 77 11 20 32 65 11 12
secondArray = np.loadtxt("C:\\Users\\user\\source\\repos\\CorelationApplication\\secondfile.txt")
corr = np.correlate(firstArray,secondArray, 'full')
result = print (corr)
# 1.2000e+01 3.5000e+01 1.2300e+02 2.9100e+02 4.7500e+02 8.5000e+02
# 1.2000e+01 3.5000e+01 1.2300e+02 2.9100e+02 4.7500e+02 8.5000e+02
# 1.2000e+01 3.5000e+01 1.2300e+02 2.9100e+02 4.7500e+02 8.5000e+02
# 1.2000e+01 3.5000e+01 1.2300e+02 2.9100e+02 4.7500e+02 8.5000e+02
return result
if __name__ == "__main__":
app.run(debug = True)
I getting this message:The view function did not return a valid response. The function either returned None or ended without a return statement
Solution
If all you need is a textual representation of an np.array, the simplest way to get there is
from flask import make_response
...
corr = np.correlate(firstArray,secondArray, 'full')
response = make_response(str(corr), 200)
response.mimetype = 'text/plain'
return response
Answered By - Dave W. Smith
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.