저는 파이썬에서 온라인 수업을 듣고 web.py를 사용하여 웹 사이트를 만들려고합니다. Windows 10 컴퓨터에서 python 3.6.1
을 실행하고 있습니다. 필자는 필요에 따라 수동으로 web.py를 설치하고 올바르게 가져 왔는지 확인했습니다. 나는 github에서 web.py의 "python3"과 "p3"브랜치를 모두 시도해 보았고 같은 문제가 발생했다.python3에 문제가 있습니다. web.py
아래의 "urls"문에 표시된 것처럼 정의 된 세 페이지의 간단한 세트라고 생각합니다. 코드를 실행하고 브라우저로 이동하여 http://localhost:8080/
을 입력하면 홈 페이지가 표시됩니다. 그러나 임의의 결과, 마치 web.application()
호출이 무작위로 URL의 요소 중 두 개를 선택하는 것과 같습니다. 내가 http://localhost:8080/register
또는 /postregistration
, 아직 때때로 브라우저가 내가 한 것처럼 해당 페이지를 렌더링 할를 입력하지
404 - Not found
500 - Key Error: '/register'
500 - Key Error: '/postregistration'
200 - Returns the Home page
200 - Returns the Registration page
200 - Returns the PostRegistration page
참고 : 나는 다음과 같은 결과 중 하나를 얻을.
나는 무엇을하고 있는지 이해할 수 없으며 강사의 예제 라인을 따르고 있다고 생각했습니다. 이견있는 사람?
import web
from Models import RegisterModel
urls = {
'/', 'Home',
'/register', 'Register',
'/postregistration', 'PostRegistration'
}
render = web.template.render("Views/Templates", base="MainLayout")
app = web.application(urls, globals())
#Classes/Routes
class Home:
def GET(self):
return render.Home()
class Register:
def GET(self):
return render.Register()
class PostRegistration:
def POST(self):
data = web.input()
reg_model = RegisterModel.RegisterModel()
reg_model.insert_user(data)
return data.username
if __name__ == "__main__":
app.run()
대단히 감사합니다! 그게 내 문제를 해결 했어. – DACone