# Like the CustomVision.ai Prediction service /url route handles url's # in the body of hte request of the form: # { 'Url': '<http url>'} @app.route('/url', methods=['POST']) @app.route('/<project>/url', methods=['POST']) @app.route('/<project>/url/nostore', methods=['POST']) @app.route('/<project>/classify/iterations/<publishedName>/url', methods=['POST']) @app.route('/<project>/classify/iterations/<publishedName>/url/nostore', methods=['POST']) @app.route('/<project>/detect/iterations/<publishedName>/url', methods=['POST']) @app.route('/<project>/detect/iterations/<publishedName>/url/nostore', methods=['POST']) def predict_url_handler(project=None, publishedName=None): try: image_url = json.loads(request.get_data().decode('utf-8'))['url'] results = predict_url(image_url) return jsonify(results) except Exception as e: print('EXCEPTION:', str(e)) return 'Error processing image' if __name__ == '__main__': # Load and intialize the model initialize() # Run the server app.run(host='0.0.0.0', port=80)
img = Image.open(imageData) results = predict_image(img) return jsonify(results) except Exception as e: print('EXCEPTION:', str(e)) return 'Error processing image', 500 # Like the CustomVision.ai Prediction service /url route handles url's # in the body of hte request of the form: # { 'Url': '<http url>'} @app.route('/url', methods=['POST']) @app.route('/<project>/url', methods=['POST']) @app.route('/<project>/url/nostore', methods=['POST']) def predict_url_handler(project=None): try: image_url = json.loads(request.get_data())['url'] results = predict_url(image_url) return jsonify(results) except Exception as e: print('EXCEPTION:', str(e)) return 'Error processing image' if __name__ == '__main__': # Load and intialize the model initialize() # Run the server app.run(host='0.0.0.0', port=80)
def init(): initialize()