Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endpoints_project3_solution.py #18

Open
bhavinkotak07 opened this issue Jun 10, 2016 · 2 comments
Open

endpoints_project3_solution.py #18

bhavinkotak07 opened this issue Jun 10, 2016 · 2 comments

Comments

@bhavinkotak07
Copy link

Test 1 FAILED: Could not make POST Request to web server
("the JSON object must be str, not 'bytes'",)

I am getting this error.
On sending the POST request from postman, it shows the desired result.

@acmujica
Copy link

I'd like to know the reason for this as well. I would like to run the endpoints_tester3.py file to pass all test.

@shparker1977
Copy link

This is an issue with the URL in line 15 of endpoints_tester3.py and being redirected (301 return code) from Flask.
Line 15 reads:
url = address + "/puppies?name=Fido&description=Playful+Little+Puppy"
Line 15 should read (slash after puppies to prevent redirection):
url = address + "/puppies/?name=Fido&description=Playful+Little+Puppy"

From http://flask.pocoo.org/docs/0.10/quickstart/#url-building

Unique URLs / Redirection Behavior
Flask’s URL rules are based on Werkzeug’s routing module. The idea behind that module is to ensure beautiful and unique URLs based on precedents laid down by Apache and earlier HTTP servers.

Take these two rules:

@app.route('/projects/')
def projects():
return 'The project page'

@app.route('/about')
def about():
return 'The about page'
Though they look rather similar, they differ in their use of the trailing slash in the URL definition. In the first case, the canonical URL for the projects endpoint has a trailing slash. In that sense, it is similar to a folder on a file system. Accessing it without a trailing slash will cause Flask to redirect to the canonical URL with the trailing slash.

In the second case, however, the URL is defined without a trailing slash, rather like the pathname of a file on UNIX-like systems. Accessing the URL with a trailing slash will produce a 404 “Not Found” error.

This behavior allows relative URLs to continue working even if the trailing slash is ommited, consistent with how Apache and other servers work. Also, the URLs will stay unique, which helps search engines avoid indexing the same page twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants