Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
credit-report-api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
credit-report-api
Commits
1aaf3d08
Commit
1aaf3d08
authored
Aug 23, 2019
by
张鹏程
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 增加文件上传功能
parent
b342e0ad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
6 deletions
+50
-6
settings.py
config/settings.py
+4
-0
ReportAnalysis_Handler.py
handler/ReportAnalysis_Handler.py
+0
-1
UpLoadFiles_Handler.py
handler/UpLoadFiles_Handler.py
+36
-0
requirements.txt
requirements.txt
+2
-1
startup.py
startup.py
+4
-2
JsonUtil.py
utils/JsonUtil.py
+4
-2
No files found.
config/settings.py
View file @
1aaf3d08
...
...
@@ -7,5 +7,9 @@ FEATURE_HOST_MY = 'http://localhost:23010'
url_reportanalysis
=
'/report'
url_uploadfiles
=
'/uploadfiles'
TO_JSON
=
FILE_PATH
+
'/to_json'
HTML_PATH
=
FILE_PATH
+
'/html'
handler/ReportAnalysis_Handler.py
View file @
1aaf3d08
...
...
@@ -74,7 +74,6 @@ class ReportAnalysis(BaseHandler):
))
self
.
flush
()
# import json
# outpath = r'/Users/zhangpengcheng/Documents/量化派代码管理/credit_report/html/provinces.json'
# with open(outpath,"w+",encoding="utf-8") as f:
...
...
handler/UpLoadFiles_Handler.py
0 → 100644
View file @
1aaf3d08
# -*- coding:utf-8 -*-
from
utils
import
JsonUtil
from
handler.Base_Handler
import
BaseHandler
from
config
import
settings
class
UpLoadFiles
(
BaseHandler
):
def
post
(
self
):
self
.
_filepath
=
self
.
get_argument
(
'filepath'
,
default
=
None
)
if
self
.
_filepath
==
None
or
self
.
_filepath
==
''
:
self
.
write
(
JsonUtil
.
build_json
(
code
=
JsonUtil
.
Constants
.
Code_Params_Error
,
mssage
=
JsonUtil
.
Constants
.
Msg_Params_Error
.
format
(
'filepath'
,
self
.
_filepath
)))
self
.
flush
()
else
:
filepath
=
self
.
_filepath
isFile
=
False
try
:
with
open
(
filepath
,
'rb'
)
as
f
:
with
open
(
settings
.
HTML_PATH
+
'/'
+
self
.
_filepath
.
split
(
'/'
)[
-
1
],
'wb+'
)
as
f_to
:
f_to
.
write
(
f
.
read
())
f_to
.
close
()
self
.
write
(
JsonUtil
.
build_json
(
code
=
JsonUtil
.
Constants
.
Code_Success
,
mssage
=
JsonUtil
.
Constants
.
Msg_Success
,
report
=
'文件上传成功'
))
f
.
close
()
self
.
flush
()
self
.
finish
()
except
IOError
as
e
:
self
.
write
(
JsonUtil
.
build_json
(
code
=
JsonUtil
.
Constants
.
Code_FileUp_Error
,
mssage
=
JsonUtil
.
Constants
.
Msg_FileUp_Error
))
self
.
flush
()
requirements.txt
View file @
1aaf3d08
...
...
@@ -7,4 +7,5 @@ SQLAlchemy==1.2.5
jupyter
paramiko
cpca
lxml
==3.8.0
\ No newline at end of file
lxml
==3.8.0
bs4
\ No newline at end of file
startup.py
View file @
1aaf3d08
...
...
@@ -14,9 +14,10 @@ from config import settings as URL
# from handler import LoanDueRateHandler
from
tornado.options
import
define
,
options
from
handler
import
ReportAnalysis_Handler
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
)
...
...
@@ -31,6 +32,7 @@ class LogFormatter(tornado.log.LogFormatter):
def
apps
():
return
Application
([
(
URL
.
url_reportanalysis
,
ReportAnalysis_Handler
.
ReportAnalysis
),
(
URL
.
url_uploadfiles
,
UpLoadFiles_Handler
.
UpLoadFiles
),
])
...
...
@@ -51,4 +53,4 @@ if __name__ == "__main__":
# http_server = tornado.httpserver.HTTPServer(app)
# http_server.bind(options.port)
# http_server.start()
# tornado.ioloop.IOLoop.instance().start()
# tornado.ioloop.IOLoop.instance().start()
\ No newline at end of file
utils/JsonUtil.py
View file @
1aaf3d08
...
...
@@ -21,7 +21,6 @@ class Constants:
Code_LoginToken_Auth_Error
=
-
2
Msg_LoginToken_Auth_Error
=
'token登陆认证错误'
Code_Error
=
-
3
Msg_Error
=
'数据异常'
...
...
@@ -31,7 +30,10 @@ class Constants:
Code_File_Error
=
-
5
Msg_File_Error
=
'文件读取错误'
Code_Analysis_Error
=
-
6
Code_FileUp_Error
=
-
6
Msg_FileUp_Error
=
'文件上传失败'
Code_Analysis_Error
=
-
7
Msg_Analysis_Error
=
'html 解析错误'
Code_Error_Value
=
506
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment