Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Riccardo Candido
Python Web Development Techdegree Student 2,790 PointsUnable to run the app after I use 'app.register_blueprint(courses_api)'
I followed everything so far, however I am stuck with Blueprint now. I get this error and I am not even sure what exactly the problem is:
$ python app.py
Traceback (most recent call last):
File "app.py", line 13, in <module>
app.register_blueprint(mailbox_api)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 889, in register_blueprint
blueprint.register(self, options, first_registration)
File "/usr/lib/python2.7/site-packages/flask/blueprints.py", line 153, in register
deferred(state)
File "/usr/lib/python2.7/site-packages/flask/blueprints.py", line 172, in <lambda>
s.add_url_rule(rule, endpoint, view_func, **options))
File "/usr/lib64/python2.7/site-packages/flask_restful/__init__.py", line 161, in _blueprint_setup_add_url_rule_patch
view_func, defaults=defaults, **options)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 976, in add_url_rule
rule = self.url_rule_class(rule, methods=methods, **options)
File "/usr/lib/python2.7/site-packages/werkzeug/routing.py", line 541, in __init__
raise ValueError('urls must start with a leading slash')
ValueError: urls must start with a leading slash
By the way, I changed the name of the variables, but I am sure I am consistent with that and that that is not the issue here.
1 Answer

Anthony Kimberly
11,049 PointsI had this same problem and was able to find in my courses.py file I was missing the slash ("/") at the beginning of one of the URIs. I had this:
api.add_resource(
Course,
'api/v1/courses/<int:id>',
endpoint='course'
)
and it should've been this:
api.add_resource(
Course,
'/api/v1/courses/<int:id>',
endpoint='course'
)
If that doesn't fix it can you post your code?