가벼운 웹 프레임 워크로 web.py를 사용하여 놀고 있습니다. 내가 내 페이지의 실제 구현을 루트 파일 대신 별도의 파일로 옮기려고 할 때 문제가 발생했습니다. 데모로, 내 core.py 파일은 다음과 같습니다 :web.py/pythonpath confusion
import web, sys, os
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
urls = (
'/', 'index'
)
app = web.application(urls, globals())
render = web.template.render('templates/')
if __name__ == "__main__":
app.run()
필자는 core.py.과 같은 수준 index.py이라는 파일로 내 구현을 이동 내 구현은 다음과 같습니다
class index:
def GET(self):
return "Hello world"
을하지만, 난 내 응용 프로그램을 실행할 때마다, 나는 오류 얻을 :
<type 'exceptions.KeyError'> at /
아무도 무슨 일이 일어나고 있는지 말해 줄 수 있습니까?