I have a machine learning model, I have made an API out of it, and hosted a flask server to make it accessible as such
server = '192.168.71.53'
port = 5000
app = Flask(__name__)
app.config['CORS_HEADERS'] = 'Content-Type'
cors = CORS(app, resources={r"/get_faces":{"origins":"http://"+server+":"+str(port)}})
@app.route('/call_method', methods=["POST"])
@cross_origin(origin=server, headers=['Content- Type','Authorization'])
def call_model():
return response
if __name__ == "__main__":
app.run(host=server, port=port )
I then created a front end in Node JS that posts a request to this method via the server and IP using this
axios.post('http://192.168.71.53:5000/call_method', dataJson)
.then(response => {
# process data } } })
The program runs fine on localhost, i ran into an issue when running the website on an ip, chrome won't let me access the camera in Node Js if i don't have a HTTPS connection, so i deployed the website on a link, and tried to access it, the camera works now but it won't post a request to my flask server, i looked into it and i read that HTTPS cant make call to HTTP, so i set up flask to HTTPS via using this
context = ('certificate.pem', 'key.pem')
app.run(host=server, port=port , ssl_context=context)
Now whenever i post a request, chrome gives a net::ERR_CERT_AUTHORITY_INVALID
error
so i decided to post a http request rather than https request, for that i had to add this to my html file
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
this gives me a net::ERR_SSL_PROTOCOL_ERROR
error on chrome and code 400, message Bad HTTP/0.9 request type HTTPStatus.BAD_REQUEST -
error on flask
I have tried several other things and nothing seems to work, can someone please help me out with this? I have been struggling with this for well over 2 weeks now