Added error handling in Flask web interface.