Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- purchases = [
- {
- "transactions": [
- {
- "items": [
- {
- "name": "My Item:",
- "price": 15.99
- }
- ],
- "name": "My Wonderful Store"
- },
- {
- "time": [
- {
- "hour bought": "02:00"
- },
- ]
- }
- ]
- }
- ]
- # GET /
- @app.route("/") # shows your whole list
- def get_purchases():
- return jsonify({"purchases": purchases})
- # GET /item
- @app.route("/item") # gets just item
- def get_statistics_loads():
- return jsonify({"items:": purchases["items"]})
- app.run(port=5000)
- import flask
- from flask import jsonify
- from flask import make_response
- app = flask.Flask(__name__)
- purchases = [
- {
- "transactions": [
- {
- "items": [
- {
- "name": "My Item:",
- "price": 15.99
- }
- ],
- "name": "My Wonderful Store"
- },
- {
- "time": [
- {
- "hour bought": "02:00"
- },
- ]
- }
- ]
- }
- ]
- # GET /
- @app.route("/") # shows your whole list
- def get_purchases():
- response = make_response(jsonify(purchases))
- response.headers["customHeader"] = "custom value"
- return response
Add Comment
Please, Sign In to add comment