Commit b8307955 authored by 张鹏程's avatar 张鹏程

修改上传文件bug

parent 682406c9
import os
from tornado.options import options
FILE_PATH = os.path.realpath(os.curdir)
FEATURE_HOST = 'http://172.20.1.131:23010'
FEATURE_HOST_MY = 'http://localhost:23010'
url_reportanalysis = '/report'
url_uploadfiles= '/uploadfiles'
settings ={
'debug' : options.debug
}
# TO_JSON = FILE_PATH+'/to_json'
# HTML_PATH = FILE_PATH+'/html'
TO_JSON = '/home/sysprd/credit-report-api/to_json'
HTML_PATH = '/home/sysprd/credit-report-api/html'
if settings['debug']:
TO_JSON = FILE_PATH+'/to_json'
HTML_PATH = FILE_PATH+'/html'
else:
TO_JSON = '/home/sysprd/credit-report-api/to_json'
HTML_PATH = '/home/sysprd/credit-report-api/html'
......@@ -42,13 +42,14 @@ class ReportAnalysis(BaseHandler):
'TransactionDetails',
'QueryInfomation'
]
# maxconnections = len(asslysis) #最大并发数
# maxconnections = 1 #最大并发数
# semlock = threading.BoundedSemaphore(maxconnections)
# t = []
# for i in range(maxconnections):
# semlock.acquire()
# t = threading.Thread(target=eval(asslysis[i]),args=(html.menu_dict,))
# t.append(threading.Thread(target=eval(asslysis[i]),args=(html.menu_dict,)))
# semlock.release()
# t.start()
# t[i].start()
PersonalInformation(html.menu_dict)
InformationSummary(html.menu_dict)
TransactionDetails(html.menu_dict)
......
......@@ -3,8 +3,16 @@
from utils import JsonUtil
from handler.Base_Handler import BaseHandler
from config import settings
import os
class UpLoadFiles(BaseHandler):
def get(self):
file_list = os.listdir(settings.HTML_PATH)
self.write(JsonUtil.build_json(code=JsonUtil.Constants.Code_Success,
mssage=JsonUtil.Constants.Msg_Success,
report={'文件列表':file_list}
))
self.flush()
self.finish()
def post(self):
# self._filepath = self.get_arguments('filepath', default=None)
try :
......@@ -42,8 +50,8 @@ class UpLoadFiles(BaseHandler):
# report='文件上传成功'
# ))
# f.close()
self.flush()
self.finish()
self.flush()
self.finish()
except IOError as e:
print(e)
......@@ -61,3 +69,5 @@ class UpLoadFiles(BaseHandler):
mssage=JsonUtil.Constants.Msg_Params_Error.format('文件名称不存在',file_name)))
self.flush()
......@@ -9,17 +9,14 @@ from tornado.ioloop import IOLoop
import tornado.log
import logging
import tornado.options
from config import settings as URL
# from handler import LoanDueRateHandler
from tornado.options import define, options
from tornado.options import options, define
define("port", default=20010, help="run on the given port ", type=int)
# define("log_path", default='/tmp', help="log path ", type=str)
define("debug", default=True, help="enable debug mode")
tornado.options.parse_command_line()
from config import settings
from handler import ReportAnalysis_Handler,UpLoadFiles_Handler
from tornado.options import define, options
define("port", default=20010, help="run on the given port ", type=int)
define("log_path", default='/tmp', help="log path ", type=str)
class LogFormatter(tornado.log.LogFormatter):
def __init__(self):
......@@ -30,27 +27,28 @@ class LogFormatter(tornado.log.LogFormatter):
)
def apps():
return Application([
(URL.url_reportanalysis, ReportAnalysis_Handler.ReportAnalysis),
(URL.url_uploadfiles, UpLoadFiles_Handler.UpLoadFiles),
(settings.url_reportanalysis, ReportAnalysis_Handler.ReportAnalysis),
(settings.url_uploadfiles, UpLoadFiles_Handler.UpLoadFiles),
])
],**settings.settings)
if __name__ == "__main__":
app = apps()
server = HTTPServer(app)
[i.setFormatter(LogFormatter()) for i in logging.getLogger().handlers]
tornado.options.parse_command_line()
# #== 本地调试
app.listen(20011)
IOLoop.instance().start()
# tornado.options.parse_command_line()
# app = apps()
# http_server = tornado.httpserver.HTTPServer(app)
# http_server.bind(options.port)
# http_server.start()
# tornado.ioloop.IOLoop.instance().start()
debug = options.debug
print(debug)
if debug:
app = apps()
server = HTTPServer(app)
[i.setFormatter(LogFormatter()) for i in logging.getLogger().handlers]
# #== 本地调试
app.listen(20011)
IOLoop.instance().start()
else:
tornado.options.parse_command_line()
app = apps()
http_server = tornado.httpserver.HTTPServer(app)
http_server.bind(options.port)
http_server.start()
tornado.ioloop.IOLoop.instance().start()
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