db = SQL("mysql://user:password.mysql.pythonanywhere-services.com:3306/user $ User_Reviews",pool_recycle = 280)The list in the left column of ontariocourts311.ca, along with the body of the page under the image intermittently fail to display (which is 'fixed' by refreshing the page). I'm a Noob, and have tried various versions of the return statement without success. Error:2019-06-05 16:39:26,765: Exception on / [GET]Traceback (most recent call last): File "flask/app.py", line 2311, in wsgi_app response = self.full_dispatch_request() File "flask/app.py", line 1834, in full_dispatch_request rv = self.handle_user_exception(e) File "flask/app.py", line 1737, in handle_user_exception reraise(exc_type, exc_value, tb) File "flask/_compat.py", line 36, in reraise raise value File "flask/app.py", line 1832, in full_dispatch_request rv = self.dispatch_request() File "flask/app.py", line 1818, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/home/mlesage/mysite/Court/application.py", line 40, in home complaints = db.execute("SELECT User_Complaint, Date, Review_Title FROM Posts") File "cs50/sql.py", line 224, in execute raise eRuntimeError: (MySQLdb._exceptions.OperationalError) (2013, 'Lost connection to MySQL server during query')[SQL: SELECT User_Complaint, Date, Review_Title FROM Posts](Background on this error at: http://sqlalche.me/e/e3q8)from cs50 import SQLfrom helpers import contacts # (a list of people stored in helpers)# Configure db to mySQL databasedb = SQL("mysql://user.mysql.pythonanywhere-services.com:3306/user$User_Reviews")#timeout = db.execute(con.query('SET GLOBAL connect_timeout=6000'))@app.route("/", methods=["GET", "POST"])def home(): reviews = [list of reviews, pulled from db, for display on page] if request.method == "POST": if User_Complaint != None: return redirect ('/') #return redirect(url_for('home', reviews = reviews, contacts = contacts)) else: return render_template("home.html", reviews = reviews, contacts = contacts) # GETS METHOD else: return render_template("home.html", reviews = reviews, contacts = contacts) Page elements should display consistently (i.e. left side list of people, reviews in center of page and text box), whether using GETS or POST method. 解决方案 It looks like the problem had to do with MySQL not having available open connections, which appears to have been fixed via the slight modification to the following line:db = SQL("mysql://user:password.mysql.pythonanywhere-services.com:3306/user$User_Reviews", pool_recycle = 280) 这篇关于如何解决此Gets服务器错误,这会导致显示问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-21 00:38