recentpopularlog in

kme : rest   80

GitHub - marshmallow-code/flask-marshmallow: Flask + marshmallow for beautiful APIs
Flask + marshmallow for beautiful APIs. Contribute to marshmallow-code/flask-marshmallow development by creating an account on GitHub.
python  flask  rest  api  framework  library 
june 2019 by kme
Big Huge Thesaurus: Synonyms, antonyms, and rhymes (oh my!) | https://words.bighugelabs.com/
Get english synonyms, antonyms, sound-alike, and rhyming words from the Big Huge Thesaurus.
language  dictionary  thesaurus  reference  webservice  rest  api  poetry  writing 
january 2019 by kme
apiary.io - How can I have multiple responses from a single endpoint with different parameters? - Stack Overflow [http://stackoverflow.com/]

12
down vote
To document multiple responses simply add it after the Response 200 like so:

## Thing [/thing/{id}]
Gets a thing but the thing id must be a prime number!

+ Parameters
+ id (string) ... ID of the thing, a prime number!

+ Model (application/json)

The thing itself.

+ Body

{
"description": "It is green"
}

### Retrieve a Single Gist [GET]
+ Response 200

[Thing][]

+ Response 400 (application/json)

{ "error" : "Invalid request" }
Note there is currently no dedicated syntax to discuss the conditions (when this response i s returned). You can discuss it anyway you like it for example:

+ Response 400 (application/json)

This response is returned when no `Thing` for given `id` exists.

+ Body
If you are using Apiary mock, keep in mind that the first response listed is returned by default, unless you say otherwise using the prefer HTTP header.
apiary  rest  api  spec  blueprint  useful 
march 2017 by kme
flask-restful/__init__.py at master · flask-restful/flask-restful · GitHub
help_on_404 = current_app.config.get("ERROR_404_HELP", True)


So, just set app.config['ERROR_404_HELP'] to False.
flask_restless  solution  flask  api  rest  errormessage 
february 2017 by kme
python - Return JSON response from Flask view - Stack Overflow


jsonify serializes the data you pass it to JSON. If you want to serialize the data yourself, do what jsonify does by building a response with status=200 and mimetype='application/json'.

from flask import json

@app.route('/summary')
def summary():
data = make_summary()
response = app.response_class(
response=json.dumps(data),
status=200,
mimetype='application/json'
)
return response

flask  rest  api  solution 
february 2017 by kme
python - How to response a unicode string in flask restful api? - Stack Overflow
make_response can actually solve the problem.


My problem was that I wanted to return raw JSON, instead of having my JSON (re)interpreted as a string, with double-quotes escaped and so forth.
json  flask  flask_restful  rest  api  webdevel  solution 
february 2017 by kme
When to use the PATCH method - The RESTful cookbook
TLDR: Patch is Update, PUT is Replace.
You can delete data with PUT, you can't with PATCH.
http  patch  rest  bestpractices  webdevel  api 
february 2017 by kme
python - List all available routes in Flask, along with corresponding functions' docstrings - Stack Overflow [http://stackoverflow.com/]
from flask import Flask, jsonify

app = Flask(__name__)

@app.route('/api', methods = ['GET'])
def this_func():
"""This is a function. It does nothing."""
return jsonify({ 'result': '' })

@app.route('/api/help', methods = ['GET'])
def help():
"""Print available functions."""
func_list = {}
for rule in app.url_map.iter_rules():
if rule.endpoint != 'static':
func_list[rule.rule] = app.view_functions[rule.endpoint].__doc__
return jsonify(func_list)

if __name__ == '__main__':
app.run(debug=True)
flask  python  webdevel  rest  api  solution 
july 2016 by kme

Copy this bookmark:





to read