This commit is contained in:
Mr Chen
2018-12-20 10:45:43 +08:00
parent c5205c2d55
commit c6b38aa996
5 changed files with 69 additions and 23 deletions
+4 -3
View File
@@ -42,15 +42,16 @@ class config:
app.config['SECRET_KEY'] = os.urandom(24)
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7)
# app.debug = True
# app.config.version = self.__version + str(time.time())
self.initDB()
self.initInitD()
self.initRoute()
app.wsgi_app = MiddleWare(app.wsgi_app)
return app
def startDebug(self):
app.debug = True
app.config.version = self.__version + str(time.time())
def initDB(self):
try:
sql = db.Sql().dbfile('default')
+31
View File
@@ -98,6 +98,37 @@ class site_api:
data['phpversion'] = tmp[0]
return public.getJson(data)
def getIndex(self, sid):
print sid
siteName = public.M('sites').where("id=?", (sid,)).getField('name')
file = self.getHostConf(siteName)
conf = public.readFile(file)
rep = "\s+index\s+(.+);"
tmp = re.search(rep, conf).groups()
return tmp[0].replace(' ', ',')
def setIndex(self, sid, index):
if index.find('.') == -1:
return public.returnJson(False, '默认文档格式不正确,例:index.html')
index = index.replace(' ', '')
index = index.replace(',,', ',')
if len(index) < 3:
return public.returnJson(False, '默认文档不能为空!')
siteName = public.M('sites').where("id=?", (sid,)).getField('name')
index_l = index.replace(",", " ")
file = self.getHostConf(siteName)
conf = public.readFile(file)
if conf:
rep = "\s+index\s+.+;"
conf = re.sub(rep, "\n\tindex " + index_l + ";", conf)
public.writeFile(file, conf)
public.writeLog('TYPE_SITE', 'SITE_INDEX_SUCCESS', (siteName, index_l))
return public.returnJson(True, '设置成功!')
def getHostConf(self, siteName):
return public.getServerDir() + '/openresty/nginx/conf/vhost/' + siteName + '.conf'