dynamic/mini_frame.py import re import pymysql import urllib.parse import logging URL_FUNC_DICT = dict() """ URL_FUNC_DICT = { "/index.py" : index, "/center.py" : center, } """ # func_list = list() def route(url): def set_func(func): # func_list.append(func) URL_FUNC_DICT[url] = func def call_func(*args, **kwargs): return func(*args, **kwargs) return call_func return set_func @route(r"/index.html") def index(ret): with open("./templates/index.html") as f: content = f.read() # my_stock_info = "这里是从mysql中查询出来的数据2..." # content = re.sub(r"\{%content%\}",my_stock_info, content) conn = pymysql