from flask import Flask
app = Flask(__name__)
@app.route('/board/<article_id>')
@app.route('/board', defaults={'article_id': 3})
def board( article_id):
print(article_id)
return article_id
if __name__ == "__main__":
app.run( host="0.0.0.0", debug=True)
책 44페이지에 이 소스
실행이 된다고 생각하시나요?
테스트는 해보고 책을 쓰신건가요?
실행하면 아래와 같이 에러가 떨어집니다.
기본적으로 확인은 해보시고 책에 소스를 싣어야 하는게 아닌가요?
이 뿐이 아닙니다..
제대로 동작하는 소스가 찾기가 어려워요..
한번 책 전체 소스를 확인해보시고 오류수정한 소스를 올려 주셔야 하는거 아닌가요..
builtins.TypeError
TypeError: 'int' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a int.
Traceback (most recent call last)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 35, in reraise
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1816, in full_dispatch_request
return self.finalize_request(rv)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1831, in finalize_request
response = self.make_response(rv)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1982, in make_response
reraise(TypeError, new_error, sys.exc_info()[2])
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\_compat.py", line 34, in reraise
raise value.with_traceback(tb)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\flask\app.py", line 1974, in make_response
rv = self.response_class.force_type(rv, request.environ)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\werkzeug\wrappers.py", line 921, in force_type
response = BaseResponse(*_run_wsgi_app(response, environ))
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\werkzeug\wrappers.py", line 59, in _run_wsgi_app
return _run_wsgi_app(*args)
File "C:\Users\loveb\AppData\Local\Programs\Python\Python36\lib\site-packages\werkzeug\test.py", line 923, in run_wsgi_app
app_rv = app(environ, start_response)
TypeError: 'int' object is not callable The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a int.
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.
You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:
dump()
shows all variables in the framedump(obj)
dumps all that's known about the object