title: flask using POST, PUT, DELETE
body: <p>I keep getting an error on the url when I try to implement POST in my API. I keep getting the error in the URL saying METHOD not Allowed for this URL. Am I missing something? Does POST not work directly when u try to open the server?? I'm soooo lost. </p>
  
  <pre><code>from flask import Flask, jsonify,json, request, abort
  from flask_sqlalchemy import SQLAlchemy
  
  
  app = Flask(__name__)
  app.config.from_pyfile('Config.py')
  db = SQLAlchemy(app)
  db.create_all()
  
  class JsonModel(object):
      def as_dict(self):
           return {c.name: getattr(self, c.name) for c in self.__table__.columns}
  
  class User(db.Model, JsonModel):
      User_ID = db.Column(db.Integer, primary_key = True)
      FirstName = db.Column(db.String(20))
      LastName = db.Column(db.String(20))
  
      def __init__(self,FirstName, LastName):
           self.FirstName = FirstName
           self.LastName = LastName
  
  class Todo(db.Model, JsonModel):
      todo_ID = db.Column(db.Integer, primary_key = True)
      UserID = db.Column(db.Integer, db.ForeignKey('User_ID'))
      details = db.Column(db.String(30))
  
      def __init__(self,details):
          self.details = details
  
  @app.route('/', methods = ['GET'])
  def index():
      return json.dumps([u.as_dict() for u in User.query.all()+Todo.query.all()])
  
  @app.route('/todo/&lt;int:UserID&gt;', methods = ['GET'])
  def get(UserID):
      return (list[Todo.query.get(UserID)])
  
  @app.route('/p/', methods = ['POST'])
  def create_dev():
      if not request.json or not 'name' in request.json:
      abort(400)
      dev = Todo(request.json.details,request.json.get('details',''))
      db.session.add(dev)
      db.session.commit()
      return json.dumps([{'dev': dev}]), 201
  
  if __name__ == '__main__':
      app.run()
  </code></pre>