Skip to content
This repository was archived by the owner on Feb 3, 2024. It is now read-only.

Conversation

@VivianNK
Copy link

No description provided.

Copy link
Contributor

@mxmeinhold mxmeinhold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited for this, but consider adjusting your route return values.

vote = Vote(quote, submitter, direction)
db.session.add(vote)
db.session.commit()
return '200'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flask responses have a couple different forms (docs).

If you return a string, it will form a response with that string as the body and a status code of 200 OK.
If you want to specify the status code or headers, you can return a tuple in either of the following forms:

  • (body, status, headers)
  • (body, headers)

This means that when you return '201', it gives a response with a body of '201' and a status code of 200 OK

You could return a JSON success message:

        return jsonify(success=True)

For line 132, you can use a similar style while specifying the response code:

		return jsonify(success=True), 201

There are a few other ways you could achieve this, this is just the one I think of first.

@dantayy dantayy merged commit 6cfc77f into ComputerScienceHouse:master Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants