Created
June 14, 2015 03:44
-
-
Save amjith/43a56b94df5735db9e85 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wrapt | |
class NotFlask(): | |
def __init__(self): | |
self.routes = {} | |
#def route(self, route_str): | |
#@wrapt.decorator | |
#def decorator(f, instance, args, kwargs): | |
#self.routes[route_str] = f | |
#return f(*args, **kwargs) | |
def route(self, route_str): | |
def decorator(f): | |
self.routes[route_str] = f | |
return f | |
return decorator | |
def serve(self, path): | |
view_function = self.routes.get(path) | |
if view_function: | |
return view_function() | |
else: | |
raise ValueError('Route "{}"" has not been registered'.format(path)) | |
app = NotFlask() | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
print app.serve("/") |
Author
amjith
commented
Jun 14, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment