显示首页
定义一个处理的函数
@route(r'/index.html')
def index(match): #match这个正则地址的对象
1.读取到Ui给个网页内容
with open(xxx) as f:
html_content = f.read()
2.得到数据库的数据
2.1连接数据
conn = connect(xxxx)
cs1 = conn.cursor()
cs1.execte(sql语句)
table_content = cs1.fellall()
cs1.close()
conn.close()
3.用正则把网页跟数据库拼接起来
html_content = re.sub(r'xxx',要替换的内容,html_content)
return html_content
删除
1.执行code去数据库执行删除
delete from focus where info_id = (select Id from info where code = xxx);
添加
1.在添加的时候需要注意判断是否已经存在,如果存在了,那么提示,如果不存在,那么添加成功
insert into focus(note_info) (select id from info where code = xxx);
更新
1.展示页面
2.更新数据
update focus set note_info = xxx where id = (select id from info where code = xxx);