Archived
feat: fix bug
This commit is contained in:
9 files changed
+208
-81
No files matched your search
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/5
|
||||
# @File Name: length.py
|
||||
|
||||
|
||||
def make_html(length: int, svg_width: int = 45, svg_height: int = 70) -> None:
|
||||
"""
|
||||
生成html
|
||||
:param svg_height:
|
||||
:param svg_width:
|
||||
:param length:
|
||||
:return:
|
||||
"""
|
||||
|
||||
html_head = """<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="%(w)s" height="%(h)s" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>{{ title }}</title>
|
||||
<g>\n"""
|
||||
svg_tag = """ <image x="%(x)s" y="0" width="%(w)s" height="%(h)s" xlink:href="{{ svg_img_%(i)s }}"></image>\n"""
|
||||
html_feet = """</g></svg>"""
|
||||
html_head = html_head % {'w': length * svg_width, 'h': svg_height} # 总体宽度
|
||||
for i in range(length): # 拼接出完整的html
|
||||
html_head += svg_tag % {'x': i * svg_width, 'w': svg_width, 'h': svg_height, 'i': i}
|
||||
html_head += html_feet # 加上结尾标签
|
||||
with open('./templates/index.html', 'w', encoding='utf-8') as template_fp: # 写入文件
|
||||
template_fp.write(html_head)
|
||||
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/5
|
||||
# @File Name: render_.py
|
||||
|
||||
|
||||
from flask import render_template
|
||||
|
||||
|
||||
def render_temp_(length: int, name: str, image_list: list) -> str:
|
||||
"""
|
||||
代码很烂写到隐蔽的地方就看不见了
|
||||
:param length:
|
||||
:param name:
|
||||
:param image_list:
|
||||
:return:
|
||||
"""
|
||||
|
||||
# 自己写的都看不下去了
|
||||
if length == 7:
|
||||
return render_template('index.html',
|
||||
title=name,
|
||||
svg_img_0=f'{image_list[0]}',
|
||||
svg_img_1=f'{image_list[1]}',
|
||||
svg_img_2=f'{image_list[2]}',
|
||||
svg_img_3=f'{image_list[3]}',
|
||||
svg_img_4=f'{image_list[4]}',
|
||||
svg_img_5=f'{image_list[5]}',
|
||||
svg_img_6=f'{image_list[6]}'
|
||||
)
|
||||
elif length == 8:
|
||||
return render_template('index.html',
|
||||
title=name,
|
||||
svg_img_0=f'{image_list[0]}',
|
||||
svg_img_1=f'{image_list[1]}',
|
||||
svg_img_2=f'{image_list[2]}',
|
||||
svg_img_3=f'{image_list[3]}',
|
||||
svg_img_4=f'{image_list[4]}',
|
||||
svg_img_5=f'{image_list[5]}',
|
||||
svg_img_6=f'{image_list[6]}',
|
||||
svg_img_7=f'{image_list[7]}'
|
||||
)
|
||||
elif length == 9:
|
||||
return render_template('index.html',
|
||||
title=name,
|
||||
svg_img_0=f'{image_list[0]}',
|
||||
svg_img_1=f'{image_list[1]}',
|
||||
svg_img_2=f'{image_list[2]}',
|
||||
svg_img_3=f'{image_list[3]}',
|
||||
svg_img_4=f'{image_list[4]}',
|
||||
svg_img_5=f'{image_list[5]}',
|
||||
svg_img_6=f'{image_list[6]}',
|
||||
svg_img_7=f'{image_list[7]}',
|
||||
svg_img_8=f'{image_list[8]}',
|
||||
)
|
||||
else:
|
||||
return render_template('index.html',
|
||||
title=name,
|
||||
svg_img_0=f'{image_list[0]}',
|
||||
svg_img_1=f'{image_list[1]}',
|
||||
svg_img_2=f'{image_list[2]}',
|
||||
svg_img_3=f'{image_list[3]}',
|
||||
svg_img_4=f'{image_list[4]}',
|
||||
svg_img_5=f'{image_list[5]}',
|
||||
svg_img_6=f'{image_list[6]}',
|
||||
svg_img_7=f'{image_list[7]}',
|
||||
svg_img_8=f'{image_list[8]}',
|
||||
svg_img_9=f'{image_list[9]}'
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
# -- coding:utf-8 --
|
||||
# @Author: markushammered@gmail.com
|
||||
# @Development Tool: PyCharm
|
||||
# @Create Time: 2022/2/5
|
||||
# @File Name: evaltest.py
|
||||
|
||||
|
||||
cmd = """return ('index.html', title=name, svg_img_0=f'{sorted_image[0]}', svg_img_1=f'{sorted_image[1]}', svg_img_2=f'{sorted_image[2]}', svg_img_3=f'{sorted_image[3]}', svg_img_4=f'{sorted_image[4]}', svg_img_5=f'{sorted_image[5]}', svg_img_6=f'{sorted_image[6]}', svg_img_7=f'{sorted_image[7]}', svg_img_8=f'{sorted_image[8]}', svg_img_9=f'{sorted_image[9]}' )"""
|
||||
|
||||
print(eval(cmd))
|
||||
Reference in New Issue
Block a user