1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Tornado Web doesn't show data

Discussão em 'Python' iniciado por Stack, Setembro 7, 2025.

  1. Stack

    Stack Membro Participativo

    I used Tornado and mysql to create a web. I checked database, all tables a created and have data,but when i opened website I found only one page(mapping to one table) shows data ,the other page(other tables) don't show any data.

    class Application(tornado.web.Application): def __init__(self): handlers = [ # 设置路由 (r"/", HomeHandler), (r"/instock/", HomeHandler), # show data frome dataTableHandler (r"/instock/api_data", dataTableHandler.GetStockDataHandler), (r"/instock/data", dataTableHandler.GetStockHtmlHandler), (r"/instock/data/indicators", dataIndicatorsHandler.GetDataIndicatorsHandler), # 加入关注 (r"/instock/control/attention", dataIndicatorsHandler.SaveCollectHandler), ] settings = dict( # 配置 template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), xsrf_cookies=False, # True, # cookie加密 cookie_secret="027bb1b670eddf0392cdda8709268a17b58b7", debug=True, ) super(Application, self).__init__(handlers, **settings) # Have one global connection to the blog DB across all handlers self.db = torndb.Connection(**mdb.MYSQL_CONN_TORNDB)

    `class GetDataIndicatorsHandler(webBase.BaseHandler, ABC): @gen.coroutine def get(self): code = self.get_argument("code", default=None, strip=False) date = self.get_argument("date", default=None, strip=False) name = self.get_argument("name", default=None, strip=False) comp_list = [] try: if code.startswith(('1', '5')): stock = stf.fetch_etf_hist((date, code)) else: stock = stf.fetch_stock_hist((date, code)) if stock is None: return

    pk = vis.get_plot_kline(code, stock, date, name)
    if pk is None:
    return

    comp_list.append(pk)
    except Exception as e:
    logging.error(f"dataIndicatorsHandler.GetDataIndicatorsHandler处理异常:{e}")

    self.render("stock_indicators.html", comp_list=comp_list,
    leftMenu=webBase.GetLeftMenu(self.request.uri))


    `

    I restarted website and database.It didm't work.

    Continue reading...

Compartilhe esta Página