input: Write a python function to return the HTTP methods allowed for a given endpoint in the Flask application.
  assert allowed_methods('/users/<userId>') == ['GET', 'POST', 'PUT', 'DELETE']
  assert allowed_methods('/courses/<courseId>') == ['GET', 'POST', 'PUT', 'DELETE']
  assert allowed_methods('/courses/<courseId>/grades') == ['GET', 'POST', 'PUT', 'DELETE']
output: from flask import Flask
  
  app = Flask(__name__)
  
  @app.route('/users/<userId>', methods=['GET', 'POST', 'PUT', 'DELETE'])
  def users(userId):
      pass
  
  @app.route('/courses/<courseId>', methods=['GET', 'POST', 'PUT', 'DELETE'])
  def courses(courseId):
      pass
  
  @app.route('/courses/<courseId>/grades', methods=['GET', 'POST', 'PUT', 'DELETE'])
  def grades(courseId):
      pass
  
  def allowed_methods(endpoint):
      with app.test_request_context():
          rule = next(rule for rule in app.url_map.iter_rules() if rule.rule == endpoint)
          return list(rule.methods - {'OPTIONS', 'HEAD'})