mirror of https://github.com/mitsuhiko/flask.git
Alaa Aqeel
7 years ago
committed by
GitHub
1 changed files with 29 additions and 0 deletions
@ -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…
Reference in new issue