mini web 创建

显示首页

定义一个处理的函数

@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);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值