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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter