文档服务地址:http://47.92.0.57:3000/ 周报索引地址:http://47.92.0.57:3000/s/NruNXRYmV

Commit 90cccc20 by 李景熙

修改数据库连接配置防止时间过长而断开

parent 1f0a43a8
...@@ -11,7 +11,6 @@ from views.imageAnnotation import image ...@@ -11,7 +11,6 @@ from views.imageAnnotation import image
from config.config import DevelopmentConfig from config.config import DevelopmentConfig
app = Flask(__name__) app = Flask(__name__)
CORS(app) CORS(app)
app.config.from_object(DevelopmentConfig) app.config.from_object(DevelopmentConfig)
...@@ -32,4 +31,4 @@ if __name__ == '__main__': ...@@ -32,4 +31,4 @@ if __name__ == '__main__':
@app.route('/') @app.route('/')
def hello(name=None): def hello(name=None):
return render_template('index.html', name=name) return render_template('index.html', name=name)
\ No newline at end of file
...@@ -7,4 +7,3 @@ mysql = MySQLDatabase( ...@@ -7,4 +7,3 @@ mysql = MySQLDatabase(
passwd='123456', passwd='123456',
charset='utf8' charset='utf8'
) )
mysql.connect()
...@@ -2,10 +2,24 @@ import json ...@@ -2,10 +2,24 @@ import json
from flask import Blueprint from flask import Blueprint
from flask import request from flask import request
from dao import User from dao import User
from dao.model import mysql
user = Blueprint("user", __name__, url_prefix="/api/user") user = Blueprint("user", __name__, url_prefix="/api/user")
@user.before_request
def db_connect():
print("!")
mysql.connect()
@user.after_request
def db_close(response):
if not mysql.is_closed():
mysql.close()
return response
@user.route("/signup", methods=["Post"]) @user.route("/signup", methods=["Post"])
def signup(): def signup():
# print("signup") # print("signup")
...@@ -42,3 +56,5 @@ def personnal_information(): ...@@ -42,3 +56,5 @@ def personnal_information():
'data': ret.data 'data': ret.data
} }
return json.dumps(res) return json.dumps(res)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment