Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
e6285c57
Commit
e6285c57
authored
May 09, 2020
by
高宇强
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gyq
parent
862ede08
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
19 deletions
+84
-19
ailogo/LogoManage.py
+30
-11
ailogo/LogoManage.py1
+0
-0
ailogo/main.py
+54
-8
No files found.
ailogo/LogoManage.py
View file @
e6285c57
...
@@ -36,10 +36,19 @@ def SaveLogoResource(inputdata,msg_id,cur):
...
@@ -36,10 +36,19 @@ def SaveLogoResource(inputdata,msg_id,cur):
# params = json.dumps(data, ensure_ascii=False)
# params = json.dumps(data, ensure_ascii=False)
sptagdata
=
[]
sptagdata
=
[]
try
:
try
:
sptagdata
=
requests
.
post
(
sptagapi
,
json
=
data1
)
.
json
()
#得到logoid
sptagdata1
=
requests
.
post
(
sptagapi
,
json
=
data1
)
.
json
()
# 得到logoid
# 过滤行业
idlist
=
[]
for
idinfo
in
sptagdata1
:
idlist
.
append
(
idinfo
[
"id"
])
select_sql
=
"select * from logo_desc where id =
%
s"
%
idinfo
[
"id"
]
cur
.
execute
(
select_sql
)
msg
=
cur
.
fetchone
()
if
msg
[
"profession"
]
==
inputdata
[
"profession"
]:
sptagdata
.
append
({
"id"
:
msg
[
"id"
]})
except
:
#若语义分析出错,随机取50个
except
:
#若语义分析出错,随机取50个
select_sql
=
'SELECT id FROM `logo_desc` WHERE type = "standard" and mark = 0 and id >= ( SELECT floor(RAND() '
\
select_sql
=
'SELECT id FROM `logo_desc` WHERE type = "standard" and mark = 0 and
profession =
%
s and
id >= ( SELECT floor(RAND() '
\
'* (SELECT MAX(id) FROM `logo_desc`))) ORDER BY id LIMIT 50'
'* (SELECT MAX(id) FROM `logo_desc`))) ORDER BY id LIMIT 50'
%
inputdata
[
"profession"
]
cur
.
execute
(
select_sql
)
cur
.
execute
(
select_sql
)
msgs
=
cur
.
fetchall
()
msgs
=
cur
.
fetchall
()
for
ms
in
msgs
:
for
ms
in
msgs
:
...
@@ -88,8 +97,6 @@ def SaveLogoResource(inputdata,msg_id,cur):
...
@@ -88,8 +97,6 @@ def SaveLogoResource(inputdata,msg_id,cur):
#把生成的单个Logo信息存入数据库
#把生成的单个Logo信息存入数据库
def
SaveSingleLogo
(
inputdata
):
def
SaveSingleLogo
(
inputdata
):
print
(
'--------------------------开始生成logo---------------------'
)
starttime
=
time
.
time
()
try
:
try
:
#3.调用云飞生成logo方法,把json_str传过去
#3.调用云飞生成logo方法,把json_str传过去
#print("调用云飞生成logo方法")
#print("调用云飞生成logo方法")
...
@@ -128,8 +135,6 @@ def SaveSingleLogo(inputdata):
...
@@ -128,8 +135,6 @@ def SaveSingleLogo(inputdata):
json_str
=
customizelogosmall
.
gen_main
(
gen_json
)
json_str
=
customizelogosmall
.
gen_main
(
gen_json
)
if
json_str
[
"status"
]:
if
json_str
[
"status"
]:
js
=
json_str
[
"image_gen_url"
]
js
=
json_str
[
"image_gen_url"
]
endtime
=
time
.
time
()
print
(
'--------------------------结束生成logo---------------------'
,
endtime
-
starttime
)
return
True
,
js
return
True
,
js
else
:
else
:
...
@@ -398,9 +403,16 @@ def ChangeABatch(inputdata):
...
@@ -398,9 +403,16 @@ def ChangeABatch(inputdata):
res
[
"font_description"
]
=
font_dec
res
[
"font_description"
]
=
font_dec
Update_sql
=
"UPDATE `logo_msg`.`logo_res` SET `pic_url`=
%
s,`font_id`=
%
s WHERE `id`=
%
s "
Update_sql
=
"UPDATE `logo_msg`.`logo_res` SET `pic_url`=
%
s,`font_id`=
%
s WHERE `id`=
%
s "
if
not
res
[
"pic_url"
]:
if
not
res
[
"pic_url"
]:
iserror
,
res
[
"pic_url"
]
=
SaveSingleLogo
(
res
)
#改成调服务
#c_url = 'http://127.0.0.1:5000/api/createlogo'
c_url
=
'http://ailogo-CreatLogo-Serverice/api/createlogo'
data1
=
requests
.
post
(
c_url
,
json
=
res
)
.
json
()
if
data1
[
"status"
]
==
0
:
res
[
"pic_url"
]
=
data1
[
"data"
]
tub
=
(
res
[
"pic_url"
],
res
[
"font_id"
],
res
[
"id"
])
tub
=
(
res
[
"pic_url"
],
res
[
"font_id"
],
res
[
"id"
])
cur
.
execute
(
Update_sql
,
tub
)
cur
.
execute
(
Update_sql
,
tub
)
else
:
iserror
=
False
try
:
try
:
connection
.
commit
()
connection
.
commit
()
except
:
except
:
...
@@ -547,9 +559,16 @@ def ReturnLogoInfo(inputdata,curpage,pagesize):
...
@@ -547,9 +559,16 @@ def ReturnLogoInfo(inputdata,curpage,pagesize):
Update_sql
=
"UPDATE `logo_msg`.`logo_res` SET `pic_url`=
%
s,`font_id`=
%
s WHERE `id`=
%
s "
Update_sql
=
"UPDATE `logo_msg`.`logo_res` SET `pic_url`=
%
s,`font_id`=
%
s WHERE `id`=
%
s "
for
r
in
list_r
:
for
r
in
list_r
:
if
not
r
[
"pic_url"
]:
if
not
r
[
"pic_url"
]:
iserror
,
r
[
"pic_url"
]
=
SaveSingleLogo
(
r
)
# 改成调服务
tub
=
(
r
[
"pic_url"
],
r
[
"font_id"
],
r
[
"id"
])
#c_url = 'http://127.0.0.1:5000/api/createlogo'
cur
.
execute
(
Update_sql
,
tub
)
c_url
=
'http://ailogo-CreatLogo-Serverice/api/createlogo'
data1
=
requests
.
post
(
c_url
,
json
=
r
)
.
json
()
if
data1
[
"status"
]
==
0
:
r
[
"pic_url"
]
=
data1
[
"data"
]
tub
=
(
r
[
"pic_url"
],
r
[
"font_id"
],
r
[
"id"
])
cur
.
execute
(
Update_sql
,
tub
)
else
:
iserror
=
False
try
:
try
:
connection
.
commit
()
connection
.
commit
()
except
:
except
:
...
...
ailogo/LogoManage.py1
deleted
100644 → 0
View file @
862ede08
This diff is collapsed.
Click to expand it.
ailogo/main.py
View file @
e6285c57
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
from
flask
import
Flask
,
render_template
,
request
from
flask
import
Flask
,
render_template
,
request
import
json
import
json
import
pymysql
import
pymysql
,
sys
,
os
from
flask_cors
import
CORS
from
flask_cors
import
CORS
import
LogoManage
import
LogoManage
import
GetLogo
import
GetLogo
...
@@ -15,6 +15,8 @@ import CreateScene
...
@@ -15,6 +15,8 @@ import CreateScene
# 服务器接口API
# 服务器接口API
interface_path
=
os
.
path
.
dirname
(
__file__
)
sys
.
path
.
insert
(
0
,
interface_path
)
# 将当前文件的父目录加入临时系统变量
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
@app.route
(
'/api/singlelogo'
,
methods
=
[
'POST'
])
@app.route
(
'/api/singlelogo'
,
methods
=
[
'POST'
])
def
SingleLogoApi
():
#获取单个logo
def
SingleLogoApi
():
#获取单个logo
...
@@ -105,12 +107,6 @@ def ChangeABatchApi():#换一批
...
@@ -105,12 +107,6 @@ def ChangeABatchApi():#换一批
profession
=
request
.
get_json
()
.
get
(
"profession"
)
profession
=
request
.
get_json
()
.
get
(
"profession"
)
if
"description"
in
request
.
get_json
()
and
request
.
get_json
()
.
get
(
"description"
):
if
"description"
in
request
.
get_json
()
and
request
.
get_json
()
.
get
(
"description"
):
description
=
request
.
get_json
()
.
get
(
"description"
)
description
=
request
.
get_json
()
.
get
(
"description"
)
# curpage =1
# pagesize =10
# if "curpage" in request.get_json() and request.get_json().get("curpage"):
# curpage = request.get_json().get("curpage")
# if "pagesize" in request.get_json() and request.get_json().get("pagesize"):
# pagesize = request.get_json().get("pagesize")
if
not
title
or
not
profession
:
if
not
title
or
not
profession
:
return
json
.
dumps
({
"status"
:
-
1
,
"msg"
:
"参数不正确"
,
"data"
:
{}},
ensure_ascii
=
False
)
return
json
.
dumps
({
"status"
:
-
1
,
"msg"
:
"参数不正确"
,
"data"
:
{}},
ensure_ascii
=
False
)
...
@@ -165,9 +161,59 @@ def DownloadSceneApi():#得到场景信息
...
@@ -165,9 +161,59 @@ def DownloadSceneApi():#得到场景信息
return
json
.
dumps
({
"status"
:
-
1
,
"msg"
:
"调用服务出错"
,
"data"
:
[]},
ensure_ascii
=
False
)
return
json
.
dumps
({
"status"
:
-
1
,
"msg"
:
"调用服务出错"
,
"data"
:
[]},
ensure_ascii
=
False
)
@app.route
(
'/api/createlogo'
,
methods
=
[
'POST'
])
#生成单个logo服务
def
CreateLogoApi
():
#得到场景信息
try
:
type
=
""
title
=
""
font_url
=
""
first_color
=
""
textpos
=
""
subtitle
=
""
sec_color
=
""
log_url
=
""
logo_id
=
0
if
"type"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"type"
):
type
=
request
.
get_json
()
.
get
(
"type"
)
if
"title"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"title"
):
title
=
request
.
get_json
()
.
get
(
"title"
)
if
"subtitle"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"subtitle"
):
subtitle
=
request
.
get_json
()
.
get
(
"subtitle"
)
if
"font_url"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"font_url"
):
font_url
=
request
.
get_json
()
.
get
(
"font_url"
)
if
"first_color"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"first_color"
):
first_color
=
request
.
get_json
()
.
get
(
"first_color"
)
if
"textpos"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"textpos"
):
textpos
=
request
.
get_json
()
.
get
(
"textpos"
)
if
"sec_color"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"sec_color"
):
sec_color
=
request
.
get_json
()
.
get
(
"sec_color"
)
if
"log_url"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"log_url"
):
log_url
=
request
.
get_json
()
.
get
(
"log_url"
)
if
"logo_id"
in
request
.
get_json
()
.
keys
()
and
request
.
get_json
()
.
get
(
"logo_id"
):
logo_id
=
request
.
get_json
()
.
get
(
"logo_id"
)
inputdata
=
{
"type"
:
type
,
"title"
:
title
,
"subtitle"
:
subtitle
,
"font_url"
:
font_url
,
"first_color"
:
first_color
,
"textpos"
:
textpos
,
"sec_color"
:
sec_color
,
"log_url"
:
log_url
,
"logo_id"
:
logo_id
}
istrue
,
pic_url
=
LogoManage
.
SaveSingleLogo
(
inputdata
)
if
istrue
:
return
json
.
dumps
({
"status"
:
0
,
"msg"
:
"成功"
,
"data"
:
pic_url
},
ensure_ascii
=
False
)
else
:
return
json
.
dumps
({
"status"
:
-
1
,
"msg"
:
"生成图像出错"
,
"data"
:
""
},
ensure_ascii
=
False
)
except
:
return
json
.
dumps
({
"status"
:
-
1
,
"msg"
:
"调用服务出错"
,
"data"
:
""
},
ensure_ascii
=
False
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
CORS
(
app
,
supports_credentials
=
True
)
#允许跨域
CORS
(
app
,
supports_credentials
=
True
)
#允许跨域
#app.run(host='172.16.18.2', port=15501, debug=True)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
80
,
debug
=
True
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
80
,
debug
=
True
)
#app.run(host='127.0.0.1', port=5000, debug=True)
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