input: Write a function to create a web API with Python and Flask that provides the current date and time when accessed through the '/datetime' endpoint. The function should initialize a Flask app, define a route to return the current date and time, and run the app if the script is executed directly.
  
  from flask import Flask
  import datetime
  
  app = Flask(__name__)
  
  @app.route('/datetime')
  def get_datetime():
      return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  
  if __name__ == '__main__':
      app.run()
  
  assert app.route['/datetime']==datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
output: 
  from flask import Flask
  import datetime
  
  app = Flask(__name__)
  
  @app.route('/datetime')
  def get_datetime():
      return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
  
  if __name__ == '__main__':
      app.run()
  