Guest User

Untitled

a guest
Dec 16th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. from flask import Flask, request, jsonify
  2.  
  3. app = Flask(__name__)
  4.  
  5.  
  6. @app.route('/subscribe', methods=['GET'])
  7. def add_subscribers():
  8. email_address = request.args.get('email')
  9. # add the subscribers to the email list
  10. try:
  11. write(email_address)
  12. return "Okay", 200
  13. except Exception as e:
  14. return e, 500
  15.  
  16.  
  17. @app.route('/list', methods=['GET'])
  18. def show_subscribers():
  19. try:
  20. mails = read()
  21. email_json = {"emails": mails}
  22. return jsonify(email_json)
  23. except Exception as e:
  24. return e, 500
  25.  
  26.  
  27. if __name__ == "__main__":
  28. app.run(debug=True)
Add Comment
Please, Sign In to add comment