Browse Source

Create methods.py

pull/2600/head
Alaa Aqeel 7 years ago committed by GitHub
parent
commit
efd3070fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 29
      flask/models/methods.py

29
flask/models/methods.py

@ -0,0 +1,29 @@
from flask.templating import render_template
class Router():
def __init__(self,app):
self.app = app
def get(self,path,function=None,html=None):
if function == None:
func = lambda **kw:render_template(str(html),**kw)
if self.app.view_functions.get(html):
func = self.app.view_functions.get(html)
self.app.add_url_rule(path,html,func,methods=["GET"])
else:
self.app.add_url_rule( path,function.__name__,function,methods=["GET"])
def post(self,path,function):
self.app.add_url_rule(path,function.__name__,function,methods=["POST"])
def put(self,path,function):
self.app.add_url_rule( path, function.__name__, function, methods=["PUT"])
def delete(self,path,function):
self.app.add_url_rule( path, function.__name__, function, methods=["DELETE"])
Loading…
Cancel
Save