You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

LPTHW ex25运行Web应用报错:module 'web' has no attribute 'config_session'

Fix AttributeError: module 'web' has no attribute 'config_session' in LPTHW ex25 Web App

The error you're hitting is caused by a straightforward typo in your app.py code. Let's break down the issue and fix it:

Root Cause

Look at the session initialization section of your code:

if web.config.get('_session')is None:
    store=web.session.DiskStore('sessions')
    session=web.session.Session(app,store,initializer={'room':None})
    web.config._session=session
else:
    session=web.config_session  # This line has the mistake!

You tried to access web.config_session, but the correct attribute is web.config._session (note the underscore between config and _session). The web.config object holds the _session attribute you set earlier, so you need to use dot notation to access it properly.

Fixed Code

Update that section to this corrected version:

if web.config.get('_session') is None:
    store = web.session.DiskStore('sessions')
    session = web.session.Session(app, store, initializer={'room': None})
    web.config._session = session
else:
    session = web.config._session  # Corrected attribute access

Next Steps After Fix

  1. Re-run your app with python3 bin/app.py
  2. Visit http://0.0.0.0:8080/ – it should now redirect to /game and load the starting room without errors
  3. As a side note, you might want to address the commented "bug here" in your POST method: currently, if form.action is an empty string, session.room will be set to None. Adjusting the condition to if session.room and form.action is not None and form.action: would handle empty input better, but that's a separate improvement for later.

内容的提问来源于stack exchange,提问作者Poppy Bee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:06:01