dever 6 سال پیش
والد
کامیت
b30b545b0e
1فایلهای تغییر یافته به همراه12 افزوده شده و 14 حذف شده
  1. 12 14
      front/api/main.py

+ 12 - 14
front/api/main.py

@@ -48,9 +48,8 @@ class Common(object):
 
 		self.referer = self.request.headers.get("Referer")
 		self.host = Demeter.host(self.data['site']['link'])
-		uri = self.getHost() + self.request.uri
+		uri = Common.getHost(self) + self.request.uri
 
-		'''
 		if not self.referer:
 			self.out('验证失败')
 
@@ -59,7 +58,6 @@ class Common(object):
 
 		if self.referer == uri:
 			self.out('验证失败')
-		'''
 
 
 		self.param = self.service.signature(self.data['site']['id'], appid, self.data['site']['appsecret'], timestamp, nonce, file, file_id, uid, status)
@@ -80,6 +78,11 @@ class Common(object):
 			self.out('未生成文件信息')
 
 		return file
+	@staticmethod
+	def getHost(self):
+		host = self.request.host.replace(':8088', '')
+		host = self.request.protocol + "://" + host
+		return host
 
 class test_path(Load):
 	@Web.setting
@@ -147,7 +150,7 @@ class test_path(Load):
 			for row in datad:
 				writer.writerow(row)
 
-		url = self.getHost();
+		url = Common.getHost(self);
 
 		file_path = url + file_path.replace(Demeter.path + 'runtime', '')
 
@@ -182,7 +185,7 @@ class convert_path(Load):
 			config = Demeter.config['redis']
 			redis.rpush(config['name'], file['id'])
 
-		url = self.getHost();
+		url = Common.getHost(self);
 
 		self.data['file'] = {
 			'status' : file['status'],
@@ -203,7 +206,7 @@ class get_path(Load):
 		self.data = {}
 		file = Common.signature(self, 2)
 
-		url = self.getHost();
+		url = Common.getHost(self);
 
 		self.data['file'] = {
 			#'id' : file['id'],
@@ -270,7 +273,7 @@ class view_path(Load):
 		num = page.replace('.page', '')
 		if limit > 0 and int(num) > limit:
 			self.out('您没有权限查看')
-		url = self.getHost();
+		url = Common.getHost(self);
 		static = url + path
 		if 'save' in Demeter.config['setting']:
 			page = path + page
@@ -283,7 +286,7 @@ class view_path(Load):
 	def getContent(self, file, limit, uid):
 		if limit < 0:
 			limit = int(file['page'])
-		url = self.getHost();
+		url = Common.getHost(self);
 		style = ['document.css']
 		script = ['jquery.js', 'layer.js']
 		content = ''
@@ -319,7 +322,7 @@ class view_path(Load):
 			File.write(view, content)
 		else:
 			content = File.readContent(file['html'])
-			url = self.getHost();
+			url = Common.getHost(self);
 
 			static = self.static(url) + 'pdf/'
 			content = content.replace('src="', 'src="' + static)
@@ -335,11 +338,6 @@ class view_path(Load):
 			content = content.replace('</head>', self.style() + '<head>')
 		return content
 
-	def getHost(self):
-		host = self.request.host.replace(':8088', '')
-		host = self.request.protocol + "://" + host
-		return host
-
 	def static(self, url):
 		return url + '/static/'