I am using the free python hosting to work on some personal python projects. I recently uploaded a flask web server. I am somewhat new to python, and flask, and not quite sure what the issue is. I am using a virtual environment of python 3.6.
When I launched my flask app, everything seems to be working as it should. However, the site will suddenly stop working and instead shows a 500 internal server error. It doesn't seem to be related to clicking on anything, or using any functionality on the website itself. It seems random.
But once I get the error, If I reload my web app, in the python anywhere control panel, the site seems to load back up, just fine. But usually within 10-30 mins the site will stop working again, and show the 500 internal server error.
When ever the site crashes, I get the following message in my error log. And the same message appears on my log whenever the site crashes.
2018-07-14 20:26:33,987: Exception on / [GET]#012Traceback (most recent call last):#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app#012 response = self.full_dispatch_request()#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request#012 rv = self.handle_user_exception(e)#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception#012 reraise(exc_type, exc_value, tb)#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise#012 raise value#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request#012 rv = self.dispatch_request()#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request#012 return self.view_functions[rule.endpoint](**req.view_args)#012 File "/home/{site name}/mysite/app.py", line 105, in index#012 year_dropdown_menu = year_dropdown_list() # Creates drop down menu options#012 File "/home/{site name}/mysite/app.py", line 23, in year_dropdown_list#012 cursor.execute('SELECT DISTINCT YEAR(time) AS Year FROM bitcoin_data ORDER BY Year DESC')#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/MySQLdb/cursors.py", line 250, in execute#012 self.errorhandler(self, exc, value)#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler#012 raise errorvalue#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/MySQLdb/cursors.py", line 247, in execute#012 res = self._query(query)#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/MySQLdb/cursors.py", line 412, in _query#012 rowcount = self._do_query(q)#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/MySQLdb/cursors.py", line 375, in _do_query#012 db.query(q)#012 File "/home/{site name}/python36_bitcoin/lib/python3.6/site-packages/MySQLdb/connections.py", line 276, in query#012 _mysql.connection.query(self, query)#012_mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away')