I am using flask to deploy my chatbot deep learning model. The model will run well when I run locally on python console. However when I try to deploy with flask, I get this exception:
Traceback (most recent call last): File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response) File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 2295, in wsgi_app
response = self.handle_exception(e) File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb) File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request() File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e) File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb) File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\_compat.py", line 35, in reraise
raise value File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request() File "C:\Users\tab\AppData\Local\Programs\Python\Python35\lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args) File "C:\Chatbot-Flask-Server-master\Chatbot-Flask-Server-master\app-.py", line 60, in prediction
response = pred(str(request.json['message'])) TypeError: 'NoneType' object is not subscriptable
Here is my code:
# webapp
app = Flask(__name__, template_folder='./')
@app.route('/prediction', methods=['POST', 'GET'])
def prediction():
response = pred(str(request.json['message']))
return jsonify(response)
@app.route('/')
def main():
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)