Developing RESTful APIs with Python and Flask

PHOTO EMBED

Thu Mar 03 2022 07:16:32 GMT+0000 (UTC)

Saved by @morristech #python

from flask import Flask, jsonify, request

app = Flask(__name__)

incomes = [
  { 'description': 'salary', 'amount': 5000 }
]


@app.route('/incomes')
def get_incomes():
  return jsonify(incomes)


@app.route('/incomes', methods=['POST'])
def add_income():
  incomes.append(request.get_json())
  return '', 204
content_copyCOPY

https://auth0.com/blog/developing-restful-apis-with-python-and-flask/