Guest User

Untitled

a guest
Nov 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. purchases = [
  2. {
  3. "transactions": [
  4. {
  5. "items": [
  6. {
  7. "name": "My Item:",
  8. "price": 15.99
  9. }
  10. ],
  11. "name": "My Wonderful Store"
  12. },
  13. {
  14. "time": [
  15. {
  16. "hour bought": "02:00"
  17. },
  18. ]
  19. }
  20. ]
  21. }
  22. ]
  23.  
  24. # GET /
  25. @app.route("/") # shows your whole list
  26. def get_purchases():
  27. return jsonify({"purchases": purchases})
  28.  
  29.  
  30. # GET /item
  31. @app.route("/item") # gets just item
  32. def get_statistics_loads():
  33. return jsonify({"items:": purchases["items"]})
  34.  
  35. app.run(port=5000)
  36.  
  37. import flask
  38. from flask import jsonify
  39. from flask import make_response
  40.  
  41. app = flask.Flask(__name__)
  42. purchases = [
  43. {
  44. "transactions": [
  45. {
  46. "items": [
  47. {
  48. "name": "My Item:",
  49. "price": 15.99
  50. }
  51. ],
  52. "name": "My Wonderful Store"
  53. },
  54. {
  55. "time": [
  56. {
  57. "hour bought": "02:00"
  58. },
  59. ]
  60. }
  61. ]
  62. }
  63. ]
  64.  
  65.  
  66. # GET /
  67. @app.route("/") # shows your whole list
  68. def get_purchases():
  69. response = make_response(jsonify(purchases))
  70. response.headers["customHeader"] = "custom value"
  71. return response
Add Comment
Please, Sign In to add comment