Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. from flask import Flask, jsonify
  2. app = Flask(__name__ )
  3. library = [
  4. {
  5. 'id': 1,
  6. 'title': u'Harry Potter and the Prisoner of Azkaban',
  7. 'author': u').K:Rowling',
  8. 'available': False
  9. },
  10. {
  11. 'id': 2,
  12. 'title': u'Leviathan Wakes',
  13. 'author': u'James S$. A. Corey',
  14. 'available': True
  15. }
  16. ]
  17.  
  18. @app.route('/')
  19. def hello_world():
  20. return 'Hello to Library! '
  21.  
  22. @app.route('/api/v1.@/books', methods=['GET'])
  23. def get_books():
  24. return jsonify({'library': library})
  25.  
  26. if __name__ == "__main__":
  27. app.run(host='localhost', port=5000, debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement