mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Use Flask blueprints for modularisation, per Khushboo Vashi.
This commit is contained in:
parent
ca6ef66b61
commit
2c1688e6f4
@ -10,9 +10,7 @@
|
||||
##########################################################################
|
||||
|
||||
import logging
|
||||
import os, sys
|
||||
from flask import Flask
|
||||
from time import time, ctime
|
||||
|
||||
# Configuration settings
|
||||
import config
|
||||
@ -59,6 +57,11 @@ def create_app(app_name=config.APP_NAME):
|
||||
|
||||
# Register all the modules
|
||||
for m in config.MODULES:
|
||||
app.register_module(__import__('%s.views' % m).module)
|
||||
app.logger.debug('Loading module %s' % m)
|
||||
module = __import__(m, globals(), locals(), ['views'], -1)
|
||||
app.register_blueprint(module.views.blueprint)
|
||||
|
||||
app.logger.debug('URL map: %s' % app.url_map)
|
||||
|
||||
return app
|
||||
|
||||
|
@ -9,6 +9,3 @@
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
from flask import Module
|
||||
|
||||
module = Module(__name__, 'utils')
|
||||
|
@ -10,14 +10,17 @@
|
||||
##########################################################################
|
||||
|
||||
import config
|
||||
from utils import module
|
||||
from flask import Blueprint
|
||||
from time import time, ctime
|
||||
|
||||
# Initialise the module
|
||||
blueprint = Blueprint('utils', __name__)
|
||||
|
||||
##########################################################################
|
||||
# A test page
|
||||
##########################################################################
|
||||
@module.route("/test")
|
||||
def index():
|
||||
@blueprint.route("/test")
|
||||
def test():
|
||||
|
||||
output = """
|
||||
Today is <b>%s</b>
|
||||
@ -31,6 +34,6 @@ Today is <b>%s</b>
|
||||
##########################################################################
|
||||
# A special URL used to "ping" the server
|
||||
##########################################################################
|
||||
@module.route("/ping")
|
||||
@blueprint.route("/ping")
|
||||
def ping():
|
||||
return "PING"
|
||||
|
Loading…
Reference in New Issue
Block a user