Skip to content

Instantly share code, notes, and snippets.

@abdounasser202
Created June 14, 2020 11:22
Show Gist options
  • Save abdounasser202/a96172d29d6a1c6087c327ca03ddc8e2 to your computer and use it in GitHub Desktop.
Save abdounasser202/a96172d29d6a1c6087c327ca03ddc8e2 to your computer and use it in GitHub Desktop.
Code: Flask-Simple - __init__.py
from flask import Blueprint
class Simple(object):
def __init__(self, app):
self.app = None
if app is not None:
self.init_app(app)
def init_app(self, app):
simple = self.register('simple')
app.register_blueprint(simple)
def register(self, name):
feature = Blueprint(name,
__name__,
template_folder='templates',
static_folder='static',
url_prefix='/simple')
feature.add_url_rule('/hello/<name>', view_func=self.hello)
return feature
def hello(self, name):
return 'hello ' + ' ' + name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment