def create_app(): print(MACROS_DIR) app.debug = True app.threaded = True app.jinja_env.auto_reload = True app.config['TEMPLATES_AUTO_RELOAD'] = True app.static_folder = STATIC_DIR loader = jinja2.ChoiceLoader([ app.jinja_loader, jinja2.FileSystemLoader([TEMPLATE_DIR, SCSS_DIR, MACROS_DIR]), ]) app.jinja_loader = loader app.jinja_env.autoescape = False app.jinja_env.undefined = SilentUndefined app.jinja_env.add_extension(CsrfExtension) app.jinja_env.add_extension(StaticFilesExtension) app.jinja_env.add_extension(ScssUrlExtension) app.jinja_env.add_extension(PaginationExtension) app.jinja_env.add_extension(jinja2.ext.do) app.jinja_env.add_extension(jinja2.ext.loopcontrols) app.jinja_env.add_extension(jinja2.ext.with_) custom_filters = { name: function for name, function in getmembers(filters) if isfunction(function) } app.jinja_env.filters.update(custom_filters) app.wsgi_app = SassMiddleware( app.wsgi_app, {'bentodev': (THEME + 'assets/sass', THEME + 'assets/css')}) return app
def server_command(args): repository = args.repository app.config.update(REPOSITORY=repository, SESSION_ID=args.session_id) app.debug = args.debug if args.no_worker: app.config.update(USE_WORKER=False) if args.profile: try: from linesman.middleware import make_linesman_middleware except ImportError: print( '-P/--profile/--linesman option is available only when ' "linesman is installed", file=sys.stderr) print('Try the following command:', file=sys.stderr) print('\tpip install linesman', file=sys.stderr) raise SystemExit else: print('Profiler (linesman) is available:', 'http://{0.host}:{0.port}/__profiler__/'.format(args)) app.wsgi_app = make_linesman_middleware(app.wsgi_app) if args.debug: app.wsgi_app = SassMiddleware( app.wsgi_app, {'earthreader.web': ('static/scss/', 'static/css/')}) app.run(host=args.host, port=args.port, debug=args.debug, threaded=True) else: serve(app, host=args.host, port=args.port)
def test_wsgi_sass_middleware_without_extension_sass(self): with tempdir() as css_dir: src_dir = os.path.join(css_dir, 'src') os.makedirs(src_dir) with open(os.path.join(src_dir, 'a.sass'), 'w') as f: f.write('a\n\tb\n\t\tcolor: blue;') app = SassMiddleware( self.sample_wsgi_app, { __name__: { 'sass_path': src_dir, 'css_path': css_dir, 'wsgi_path': '/static', 'strip_extension': True, }, }, ) client = Client(app, Response) r = client.get('/static/a.css') assert r.status_code == 200 expected = ( 'a b {\n color: blue; }\n\n' '/*# sourceMappingURL=../a.css.map */' ) self.assertEqual(expected.encode(), r.data) assert r.mimetype == 'text/css'
def test_wsgi_sass_middleware(self): with tempdir() as css_dir: src_dir = os.path.join(css_dir, 'src') shutil.copytree('test', src_dir) app = SassMiddleware( self.sample_wsgi_app, { __name__: (src_dir, css_dir, '/static'), }, ) client = Client(app, Response) r = client.get('/asdf') assert r.status_code == 200 self.assertEqual(b'/asdf', r.data) assert r.mimetype == 'text/plain' r = client.get('/static/a.scss.css') assert r.status_code == 200 self.assertEqual( b(A_EXPECTED_CSS_WITH_MAP), r.data, ) assert r.mimetype == 'text/css' r = client.get('/static/not-exists.sass.css') assert r.status_code == 200 self.assertEqual(b'/static/not-exists.sass.css', r.data) assert r.mimetype == 'text/plain'
def runserver(host, port, threaded, processes, passthrough_errors, debug, reload): """Run the Flask development server i.e. app.run()""" if flask_app.debug: # scss compile automatically in debug mode flask_app.wsgi_app = SassMiddleware(flask_app.wsgi_app, { 'cliche.web': ('static/sass', 'static/css', '/static/css') }) if debug is None: debug = flask_app.debug if reload is None: reload = flask_app.debug flask_setup_sentry() flask_app.run(host=host, port=port, debug=debug, use_debugger=debug, use_reloader=reload, threaded=threaded, processes=processes, passthrough_errors=passthrough_errors)
def create_app(): app = flask.Flask(__name__) app.config.from_object('phlox.config.Config') # Sass support app.wsgi_app = SassMiddleware( app.wsgi_app, {'phlox': ('static/scss', 'static/css', 'static/css')}) # Create instance dir os.makedirs(app.instance_path, exist_ok=True) # Create database import phlox.db app.db = phlox.db.AutosaveDict(filename=os.path.join( app.instance_path, app.config['DATABASE_FILE']), data=phlox.db._BASE_SETTINGS) # Blueprints app.register_blueprint(panel) app.register_blueprint(admin) app.register_blueprint(api) @app.route('/') def index(): return flask.redirect(flask.url_for('admin.status_selection')) return app
def create_app(config_filename, debug=False): app = Flask(__name__) app.config.from_object(config_filename) app.login_manager = login_manager log = logging.getLogger('werkzeug') db.init_app(app) CSRFProtect(app) login_manager.init_app(app) app.register_blueprint(indexController.blueprint) app.register_blueprint(quotesController.blueprint) app.register_blueprint(macrosController.blueprint) app.register_blueprint(statsController.blueprint) app.register_blueprint(loginController.blueprint) if debug: log.setLevel(logging.NOTSET) app.logger.setLevel(logging.NOTSET) # compile SCSS to CSS with every request. # useful for updating/debugging styles. app.wsgi_app = SassMiddleware( app.wsgi_app, {'app': ('static/scss', 'static/css', 'static/css')}) else: log.setLevel(logging.INFO) app.logger.setLevel(logging.INFO) # compile once at start. build_directory("app/static/scss", "app/static/css") return app
def create_app(test_config: dict = None) -> Any: """ creates flask app .""" app: Any = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY='dev', DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'), ) app.wsgi_app = SassMiddleware( app.wsgi_app, {__name__: ('static/sass', 'static/css', '/static/css')}) if test_config is None: # Load the instance config, if it exists, when not testing app.config.from_pyfile('config.py', silent=True) else: # Load the test config if passed in app.config.from_mapping(test_config) # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass # register app's dependencies from .controller import home, menu, reservation app.register_blueprint(home.HomeController.home_bp) app.register_blueprint(menu.MenuController.menu_bp) app.register_blueprint(reservation.ReservationController.reservation_bp) FlaskInjector(app=app, modules=[configure]) return app
def create_app(test_config=None, extra_config_settings={}): """Create and configure an instance of the Flask application.""" app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( # a default secret that should be overridden by instance config SECRET_KEY="dev", # store the database in the instance folder DATABASE=os.path.join(app.instance_path, "python_flask_example.sqlite"), ) # 'strip_extension': False, app.wsgi_app = SassMiddleware( app.wsgi_app, { 'python_flask_example': { 'sass_path': 'static/sass', 'css_path': 'static/css', 'wsgi_path': 'static/css', 'strip_extension': False, } }) if test_config is None: # load the instance config, if it exists, when not testing app.config.from_pyfile("config.py", silent=True) else: # load the test config if passed in app.config.update(test_config) # ensure the instance folder exists try: os.makedirs(app.instance_path) except OSError: pass @app.route("/hello") def hello(): return "Hello, World!" # register the database commands from python_flask_example import db db.init_app(app) # apply the blueprints to the app from python_flask_example import auth, blog app.register_blueprint(auth.bp) app.register_blueprint(blog.bp) # make url_for('index') == url_for('blog.index') # in another app, you might define a separate main index here with # app.route, while giving the blog blueprint a url_prefix, but for # the tutorial the blog will be the main index app.add_url_rule("/", endpoint="index") return app
def create_app(): """ Create a HubGrep Flask-app. """ app = Flask(__name__, static_url_path="/static", static_folder="static") assets = Environment(app) # disable cache, because that breaks # prod build for some reason. # maybe add to the flask config? assets.cache = False assets.manifest = False @app.after_request def add_gnu_tp_header(response): # www.gnuterrypratchett.com response.headers.add("X-Clacks-Overhead", "GNU Terry Pratchett") return response config_mapping = { constants.APP_ENV_BUILD: "hubgrep.config.BuildConfig", constants.APP_ENV_DEVELOPMENT: "hubgrep.config.DevelopmentConfig", constants.APP_ENV_PRODUCTION: "hubgrep.config.ProductionConfig", constants.APP_ENV_TESTING: "hubgrep.config.TestingConfig", } app_env = os.environ.get("APP_ENV", constants.APP_ENV_DEVELOPMENT) print(f"starting in {app_env} config") app.config.from_object(config_mapping[app_env]) if app.config['WATCH_SCSS']: app.wsgi_app = SassMiddleware(app.wsgi_app, app.config["SASS_MANIFEST"]) babel = Babel(app) init_logging(loglevel=app.config["LOGLEVEL"]) db.init_app(app) migrate.init_app(app, db=db) from hubgrep.frontend_blueprint import frontend from hubgrep.cli_blueprint import cli_bp app.register_blueprint(frontend) app.register_blueprint(cli_bp) @babel.localeselector def get_locale(): lang = request.accept_languages.best_match(app.config["LANGUAGES"].keys()) return lang app.jinja_env.globals["get_locale"] = get_locale app.jinja_env.globals["constants"] = constants app.jinja_env.globals["timeago"] = timeago app.jinja_env.globals["datetime_now"] = datetime.datetime.now() app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True return app
def create_app(): """Initialize the core application and load the config.""" # Initialize the app app = Flask(__name__, instance_relative_config=True) # app.config.from_object('config') # Get config file if environ.get("FLASK_ENV").startswith("dev"): app.config.from_object("config.DevConfig") else: app.config.from_object("config.ProdConfig") print(f'ENV is set to: {app.config["ENV"]}') # Initialize Plugins db.init_app(app) ma.init_app(app) with app.app_context(): # Configure SaaS compile app.wsgi_app = SassMiddleware( app.wsgi_app, { 'app': { 'sass_path': 'static/styles', 'css_path': 'static/css', 'wsgi_path': '/static/css', 'strip_extension': True }, }) # DB config migrate = Migrate(app, db, compare_type=True) # importing the models to make sure they are known to Flask-Migrate from .models import person, barcode # prevent cached responses if app.config["DEBUG"]: @app.after_request def after_request(response): response.headers[ "Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0" response.headers["Expires"] = 0 response.headers["Pragma"] = "no-cache" return response # import routes from . import views return app # VERY LAST import # from app import views, models
def create_app(): app = Flask(__name__) app.url_map.strict_slashes = False app.config.from_pyfile("config.cfg") app.wsgi_app = SassMiddleware( app.wsgi_app, {f"{__name__}": ("static/sass", "static/css", "/static/css")}) from routes.auth import auth app.register_blueprint(auth) from routes.main import main app.register_blueprint(main) @app.errorhandler(403) def does_not_exist(err): return render_template( "errors/client.html", code="403", title="403 Forbidden", message="You do not have access to this page."), 403 @app.errorhandler(404) def does_not_exist(err): return render_template("errors/client.html", code="404", title="404 Not Found", message="Page not found."), 404 @app.errorhandler(500) def does_not_exist(err): return render_template("errors/error.html", title="500 Server Error"), 500 login_manager = LoginManager() login_manager.session_protection = "strong" login_manager.login_view = "auth.login" login_manager.init_app(app) @login_manager.user_loader def load_user(username: str): return User(username, True) limiter = Limiter(app, key_func=get_remote_address, default_limits=["1 per second"]) @limiter.request_filter def ip_whitelist(): return request.remote_addr == "127.0.0.1" SeaSurf(app) return app
def create_app(config_object=config.Config): import life_scheduler.auth.models import life_scheduler.board.models import life_scheduler.scheduler.models import life_scheduler.trello.models import life_scheduler.routes import life_scheduler.auth.routes import life_scheduler.board.routes import life_scheduler.board.api_routes import life_scheduler.board.cli_routes import life_scheduler.google.routes import life_scheduler.scheduler.routes import life_scheduler.trello.routes root_folder = os.path.dirname(os.path.dirname(__file__)) app = Flask( __name__, static_folder=os.path.join(root_folder, "static"), template_folder=os.path.join(root_folder, "templates"), ) app.config.from_object(config_object) db.init_app(app) db_migrate.init_app(app, db) login_manager.init_app(app) feature_flag.init_app(app) app.register_blueprint(life_scheduler.routes.blueprint) app.register_blueprint(life_scheduler.auth.routes.blueprint) app.register_blueprint(life_scheduler.board.api_routes.blueprint) app.register_blueprint(life_scheduler.board.routes.blueprint) app.register_blueprint(life_scheduler.google.routes.blueprint) app.register_blueprint(life_scheduler.scheduler.routes.blueprint) app.register_blueprint(life_scheduler.trello.routes.blueprint) app.wsgi_app = SassMiddleware( app.wsgi_app, { 'life_scheduler': { 'sass_path': os.path.join(app.static_folder, 'sass'), 'css_path': os.path.join(app.static_folder, 'css'), 'wsgi_path': '/static/css', 'strip_extension': True, }, }, ) return app
def create_app(config_name): app = Flask(__name__) Material(app) app.config.from_object(config_options[config_name]) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/authenticate') app.wsgi_app = SassMiddleware( app.wsgi_app, {'app': ('static/sass', 'static/css', '/static/css')}) db.init_app(app) login_manager.init_app(app) return app
def create_app(): app = Flask(__name__) app.config.from_mapping(SECRET_KEY="dev") app.config.from_object(Config) app.wsgi_app = SassMiddleware( app.wsgi_app, {'crud_n_sass': ('static/sass', 'static/css', '/static/css')}) db = MongoEngine() db.init_app(app) from crud_n_sass import todo app.register_blueprint(todo.bp) app.add_url_rule("/", endpoint="index") return app
def serve(report, host="localhost", port=8080, debug=True): app = Flask(__name__) app.wsgi_app = SassMiddleware( app.wsgi_app, {__name__: ('static/sass', 'static/css', '/static/css')}) try: formatter = pygments.formatters.HtmlFormatter(style="arduino") except pygments.util.ClassNotFound: formatter = pygments.formatters.HtmlFormatter() css = formatter.get_style_defs('.highlight') @app.route("/") def index(): return render_template("index.html", report=report) @app.route("/hooks") def hooks(): return jsonify({k: v.__dict__ for (k, v) in report.hooks.items()}) @app.route("/hooks/<md5>/") def hook(md5): if md5 in report.hooks: h = report.hooks[md5] return render_template("hook.html", report=report, hook=h, analysis=report.get_hook_analysis(h)) else: return "invalid hash", 404 @app.route("/hooks/<md5>/callgraph") def callgraph(md5): if md5 in report.hooks: return jsonify(report.get_cg(report.hooks[md5])) else: return "invalid hash", 404 @app.route("/static/css/pygments.css") def pygments_css(): return Response(css, mimetype="text/css") app.run(host, port, debug)
def test_wsgi_sass_middleware_without_extension(self): with tempdir() as css_dir: src_dir = os.path.join(css_dir, 'src') shutil.copytree('test', src_dir) app = SassMiddleware( self.sample_wsgi_app, { __name__: { 'sass_path': src_dir, 'css_path': css_dir, 'wsgi_path': '/static', 'strip_extension': True, }, }, ) client = Client(app, Response) r = client.get('/static/a.css') assert r.status_code == 200 expected = A_EXPECTED_CSS_WITH_MAP.replace('.scss.css', '.css') self.assertEqual(expected.encode(), r.data) assert r.mimetype == 'text/css'
def create_web_app(app: App) -> Flask: wsgi = Flask(__name__) wsgi.register_blueprint(ep) wsgi.register_blueprint(admin) wsgi.teardown_request(close_session) wsgi.errorhandler(NoResultFound)(handle_no_result_found) wsgi.jinja_env.filters['kst'] = to_kst wsgi.config.update(app.web_config) wsgi.config['APP'] = app wsgi.secret_key = app.secret_key wsgi.wsgi_app = SassMiddleware(wsgi.wsgi_app, { 'pycon2018': ('static/css', 'static/css', 'static/css') }) login_manager.init_app(wsgi) if wsgi.config.get('CDN_DOMAIN'): cdn = CDN() cdn.init_app(wsgi) if app.sentry_dsn: Sentry(wsgi, dsn=app.sentry_dsn) return wsgi
def create_app(config_class=Config): app = Flask(__name__) app.logger.info(f'Starting application') app.config.from_object(config_class) app.wsgi_app = SassMiddleware( app.wsgi_app, { 'lada': { 'sass_path': 'static/sass', 'css_path': 'static/css', 'wsgi_path': '/static/css', 'strip_extension': False }, }) # extenstions db.init_app(app) migrate.init_app(app, db) login.init_app(app) mail.init_app(app) pagedown.init_app(app) markdown.init_app(app) feature_flags.init_app(app) # blueprint registrations from lada.base import bp as base_bp app.register_blueprint(base_bp) from lada.article import bp as article_bp app.register_blueprint(article_bp, url_prefix='/article') from lada.fellow import bp as fellow_bp app.register_blueprint(fellow_bp, url_prefix='/fellow') from lada.dike import bp as dike_bp app.register_blueprint(dike_bp, url_prefix='/dike') @app.context_processor def inject_version(): return {"version": app.config["VERSION"]} return app
def init_app(app): if app.config['DEBUG']: # If we're debugging, we want to build SASS for each # request so that we have a nice development flow: # # http://hongminhee.org/libsass-python/frameworks/flask.html # # However, because nginx intercepts everything at /static/, we can't # have the SASS middleware use that path, so instead we'll # put all compiled SASS in a different path that we have # control over. app.jinja_env.globals['COMPILED_SASS_ROOT'] = '/sass-middleware' app.wsgi_app = SassMiddleware(app.wsgi_app, { 'app': (SASS_DIR, CSS_DIR, app.jinja_env.globals['COMPILED_SASS_ROOT']) }) app.wsgi_app = AutoprefixingMiddleware( app.wsgi_app, app.jinja_env.globals['COMPILED_SASS_ROOT'] ) else: app.jinja_env.globals['COMPILED_SASS_ROOT'] = '/' + CSS_DIR
def init_app(app): # Custom JINJA2 filters @app.template_filter() def filter_errors(form_errors): errs = set() for key, values in form_errors.items(): for err in values: errs.add(err) return list(errs) app.jinja_env.filters['filter_errors'] = filter_errors # CSS/JS minimify and SASS compile. minify(app=app, html=True, js=True, cssless=True, script_types=['text/javascript'], bypass=['.*\\.min\\.js']) app.wsgi_app = SassMiddleware( app.wsgi_app, {'sandwalker': ('static/sass', 'static/css', '/static/css')})
def test_wsgi_sass_middleware(self): css_dir = tempfile.mkdtemp() src_dir = os.path.join(css_dir, 'src') shutil.copytree('test', src_dir) try: app = SassMiddleware(self.sample_wsgi_app, {__name__: (src_dir, css_dir, '/static')}) client = Client(app, Response) r = client.get('/asdf') self.assertEqual(200, r.status_code) self.assert_bytes_equal(b'/asdf', r.data) self.assertEqual('text/plain', r.mimetype) r = client.get('/static/a.scss.css') self.assertEqual(200, r.status_code) src_path = normalize_path(os.path.join(src_dir, 'a.scss')) self.assert_bytes_equal( b(A_EXPECTED_CSS_WITH_MAP.replace('SOURCE', src_path)), r.data) self.assertEqual('text/css', r.mimetype) r = client.get('/static/not-exists.sass.css') self.assertEqual(200, r.status_code) self.assert_bytes_equal(b'/static/not-exists.sass.css', r.data) self.assertEqual('text/plain', r.mimetype) finally: shutil.rmtree(css_dir)
# don't require HMAC_KEY to be defined for local dev os.environ['HMAC_KEY'] = base64.b64encode(b'').decode() # Stop the app from reloading/initing twice print("reloading", os.environ.get('WERKZEUG_RUN_MAIN'), os.environ) if os.environ.get('FLASK_DEBUG') is not None and os.environ.get( 'WERKZEUG_RUN_MAIN') != 'true': raise ValueError('Prevented reload') # live building of scss from sassutils.wsgi import SassMiddleware, Manifest app.wsgi_app = SassMiddleware( app.wsgi_app, { 'overtrack_web': Manifest( '../static/scss', '../static/css', '/static/css', strip_extension=True, ) }) # Force js to be unminified orig_url_for = flask.url_for def url_for(endpoint, **values): if endpoint == 'static' and 'filename' in values and values[ 'filename'].endswith('.min.js'): values['filename'] = values['filename'][:-len('.min.js')] + '.js' return orig_url_for(endpoint, **values)
from sassutils.wsgi import SassMiddleware from flask_session import Session from flask_wtf.csrf import CSRFProtect from flask_sqlalchemy import SQLAlchemy from controllers import * app = Flask(__name__, template_folder='views') db = SQLAlchemy(app) app.config.from_object('config') #CSRFProtect(app) Session(app) app.jinja_env.add_extension('pypugjs.ext.jinja.PyPugJSExtension') app.wsgi_app = SassMiddleware(app.wsgi_app, {'static': ('sass/', 'css/', '/static/css')}) app.register_blueprint(common_controller) app.register_blueprint(website_controller) app.register_blueprint(video_controller) # Error handling is made here because of # http://flask.pocoo.org/docs/0.10/api/#flask.Blueprint.errorhandler @app.errorhandler(404) def not_found(error): return render_template('errors/404.pug'), 404 if __name__ == "__main__": app.run()
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash, Markup, jsonify, Response from sassutils.wsgi import SassMiddleware from datetime import datetime from math import ceil from random import randint from titlecase import titlecase from werkzeug.security import generate_password_hash, check_password_hash import flask_login app = Flask(__name__) app.config.from_object(__name__) login_manager = flask_login.LoginManager() login_manager.init_app(app) app.wsgi_app = SassMiddleware( app.wsgi_app, {'decky': ('static/sass', 'static/css', '/static/css')}) app.config.update( dict( DEBUG = True, DATABASE=os.path.join(app.root_path, 'decky.db'), SECRET_KEY='development key', USERNAME='******', PASSWORD='******')) print app.root_path @login_manager.user_loader def load_user(user_id): print User.get(user_id) return User.get(user_id)
def create_app(): app = Flask(__name__) app.config.from_envvar("FLASK_CONFIG") app.wsgi_app = SassMiddleware( app.wsgi_app, {"www_kozea": ("static/sass", "static/css", "/static/css", False)}, ) page_data = { "home": { "cards": [ { "icon": "images/service-pharminfo.svg", "title": "Votre pharmacie disponible 24h/24", "body": "Site internet avec réservation d'ordonnance, " "Click & Collect, vente en ligne.", "page": "pharminfo", }, { "icon": "images/service-kozea-media.svg", "title": "Votre communication maîtrisée et externalisée", "body": "Réseaux sociaux, rédaction d'articles, " "création visuelle, régie média.", "page": "kozea-media", }, { "icon": "images/service-backoffice.svg", "title": "Votre tiers-payant géré de A à Z", "body": "Délégation, formation, gestion en interne.", "page": "backoffice", }, { "icon": "images/service-promomaker.svg", "title": "Vos campagnes promotionnelles en 1 clic", "body": "Outil simple et accessible pour votre PLV.", "page": "promomaker", }, ] }, "solutions": { "cards": [ { "cover": "images/pharminfo-mini-solutions.png", "headline": "Pharminfo.fr", "title": "Votre pharmacie disponible 24h/24 et 7j/7", "body": "Des services adaptés pour vous et vos patients :", "features": [ "Envoi d'ordonnance", "Click and Collect", "Vente en ligne", "Prise de rendez-vous", ], "page": "pharminfo", }, { "cover": "images/kozea-media-mini-solutions.png", "headline": "Kozea media", "title": "Votre communication maîtrisée et externalisée", "body": "Kozea media conseille depuis 10 ans les acteurs " "de santé dans leur transformation digitale.", "features": [ "Gestion des réseaux sociaux", "Régie média (publicité)", "Création graphique et contenu rédactionnel", ], "page": "kozea-media", }, { "cover": "images/backoffice-mini-solutions.png", "headline": "Backoffice", "title": "Votre tiers-payant géré de A à Z", "body": "Redonnez de la valeur à votre métier de " "pharmacien et gagnez du temps sur vos tâches " "administratives !", "features": [ "Externalisation du tiers-payant", "Formations adaptées à l'équipe officinale", "Suivi et contrôle en toute autonomie", ], "page": "backoffice", }, { "cover": "images/promomaker-mini-solutions.png", "headline": "Promomaker", "title": "Vos campagnes promotionnelles en 1 clic", "body": "Créez et diffusez très simplement des campagnes " "de communication et de promotion pour votre pharmacie.", "features": [ "Création automatique", "Accessible pour tous et pour votre groupement", "Choix du format d'impression", ], "page": "promomaker", }, ], "cards_alt": [ { "title": "Mise à jour de votre site internet", "body": "Augmentez votre référencement sur internet pour " "plus de trafic en officine.", "page": "pharminfo", }, { "title": "Animation des réseaux sociaux", "body": "Soyez au plus proche de vos patients et " "optimisez votre présence en ligne.", "page": "kozea-media", }, { "title": "Création de vos contenus rédactionnels et " "graphiques", "body": "Valorisez votre communication et l'image de " "votre pharmacie.", "page": "kozea-media", }, { "title": "Gestion de votre tiers-payant", "body": "Déléguez les tâches administratives pour vous " "recentrer sur votre cœur de métier.", "page": "backoffice", }, ], }, "pharminfo": { "cards": [ { "icon": "images/pharminfo-ordonnance.svg", "title": "Envoi d'ordonnance", }, { "icon": "images/pharminfo-click-collect.svg", "title": "Click and Collect", }, { "icon": "images/pharminfo-vente.svg", "title": "Vente en ligne", }, { "icon": "images/pharminfo-rendez-vous.svg", "title": "Prise de rendez-vous en ligne", }, ], "cards_alt": [ { "title": "Ecoweb", "body": "Site internet vitrine", }, { "title": "Flexiweb+", "body": "Envoi d'ordonnance et prise de rendez-vous " "en ligne", }, { "title": "Click and Collect", "body": "Commande en ligne avec retrait et paiement " "en pharmacie", }, { "title": "Optiweb", "body": "Vente en ligne avec une base de plus de " "8000 produits " "et la synchronisation possible avec votre LGO", }, ], }, "kozea-media": { "cards": [ { "icon": "images/kozea-media-gestion.svg", "title": "Gestion des réseaux sociaux", "body": "Facebook & Instagram", }, { "icon": "images/kozea-media-creation.svg", "title": "Création graphique", "body": "Logo, affiche, charte graphique, thème " "personnalisé pour votre site internet", }, { "icon": "images/kozea-media-redaction.svg", "title": "Contenu rédactionnel", "body": "Article de blog, newsletter", }, { "icon": "images/kozea-media-conseil.svg", "title": "Conseil stratégie digitale", "body": "Plan d'actions, accompagnement", }, { "icon": "images/kozea-media-regie.svg", "title": "Régie média", "body": "Gestion d'espaces publicitaires, plan média", }, ] }, "backoffice": { "cards": [ { "icon": "images/backoffice-gestion.svg", "title": "Pour gérer votre tiers-payant en interne", "body": "Nous mettons à votre disposition un outil web " "facile d'utilisation avec un contrôle simple et rapide " "de vos rejets", }, { "icon": "images/backoffice-externalisation.svg", "title": "Un service d'externalisation pour plus de " "liberté", "body": "Déléguez l'ensemble de la gestion de votre " "tiers-payant à nos experts !", }, { "icon": "images/backoffice-formation.svg", "title": "Pour comprendre et approfondir la gestion du " "tiers-payant", "body": "Nous proposons plusieurs offres de formations " "pour les débutants comme pour les plus experts !", }, ] }, "groupement": { "cards": [ { "icon": "images/service-pharminfo.svg", "title": "Site internet pour mettre en avant votre " "groupement et vos adhérents", "body": "Vitrine pour votre groupement et des services " "adaptés comme la réservation d'ordonnances, le Click & " "Collect, la vente en ligne ou la prise de rendez-vous " "en ligne", "page": "pharminfo", }, { "icon": "images/service-kozea-media.svg", "title": "Votre communication maîtrisée et externalisée", "body": "Réseaux sociaux, rédaction d'articles, " "création visuelle, régie média : pour vous et vos " "adhérents.", "page": "kozea-media", }, { "icon": "images/service-backoffice.svg", "title": "Le tiers-payant de vos adhérents géré de A à Z", "body": "Délégation, formation, gestion en interne : " "recentrez le pharmacien sur son cœur de métier.", "page": "backoffice", }, { "icon": "images/service-promomaker.svg", "title": "Vos campagnes promotionnelles en 1 clic", "body": "Outil simple et accessible pour uniformiser " "vos PLV (Publicités sur Lieu de Vente).", "page": "promomaker", }, ] }, "à-propos": { "cards": [ { "icon": "images/service-pharminfo.svg", "title": "Création de sites internet", "page": "pharminfo", }, { "icon": "images/service-kozea-media.svg", "title": "Gestion de la communication digitale", "page": "kozea-media", }, { "icon": "images/service-backoffice.svg", "title": "Gestion du tiers-payant", "page": "backoffice", }, { "icon": "images/service-promomaker.svg", "title": "Créations d'affiches promotionnelles", "page": "promomaker", }, ], "cards_alt": [ { "title": "J'aide ma pharmacie", "body": "Augmentez votre référencement sur internet pour " "plus de trafic en officine.", "url": "https://www.jaidemapharmacie.fr/", }, { "title": "Engagé pour la e-santé", "body": "Nous sommes fiers de faire partie des " "signataires de la charte «Engagé pour la e-santé» aux " "côtés du Ministère des Solidarités et de la Santé", "url": "https://esante.gouv.fr/sites/default/files/" "media_entity/documents/charte-engage-pour-la-e-sante" "-06-06-21.pdf", }, { "title": "Femmes de santé", "body": "Nous soutenons également le collectif «Femmes " "de santé» en signant leur charte et en nous engageant " "vers une meilleure visibilité des femmes expertes dans " "le secteur de la santé.", "url": "https://www.femmesdesante.fr/", }, ], }, } for page in PAGE_LIST: create_endpoint(app, page, page_data) @app.route("/") def home(): return render_template( "home.html", page="home", data=page_data.get("home"), menu_list=MENU_LIST, ) app.add_template_global(datetime) from . import blog app.register_blueprint(blog.bp) return app
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) ##option to tell SQLALchemy that for every model it should just #look at the columns that already exist in the table. This is called reflecting db.Model.metadata.reflect(db.engine) class Congress(db.Model): __tablename__ = 'sen' __table_args__ = {'extend_existing': True} id = db.Column(db.Text, primary_key=True) # Ensure templates are auto-reloaded app.config["TEMPLATES_AUTO_RELOAD"] = True ## access sass app.wsgi_app = SassMiddleware( app.wsgi_app, { 'app': ('static/assets/sass', 'app/static/assets/css/light-bootstrap-dashboard.css', 'app/static/assets/css/light-bootstrap-dashboard.css') }) # Custom filter app.jinja_env.filters["usd"] = usd from app import routes
from flask import Flask, render_template, request, redirect, url_for from form_utils import ContactForm, handleContactForm from flask_wtf.csrf import CSRFProtect # from sassutils.wsgi import SassMiddleware; from sassutils.wsgi import SassMiddleware; from dotenv import load_dotenv load_dotenv() app = Flask(__name__) app.secret_key = os.getenv('APP_SECRET_KEY') # app.secret_key = os.environ.get('APP_SECRET_KEY') app.wsgi_app = SassMiddleware(app.wsgi_app, { 'server': ('static/sass', 'static/css', '/static/css') }) csrf = CSRFProtect() csrf.init_app(app) # ROUTES @app.route('/') def index(): return render_template('index.html') @app.route('/projects') def projects(): return render_template('projects.html') @app.route('/about')
@app.route('/') @app.route('/<template_name>') def pages(template_name='index'): if Path(f'templates/{template_name}.html').exists(): return render_template(f'{template_name}.html') abort(404) @app.route('/docs/<name>') def rest(name): with open(f'templates/{name}.rst') as fd: html = docutils.core.publish_parts( source=fd.read(), writer=docutils.writers.html5_polyglot.Writer(), settings_overrides={'initial_header_level': 2})['body'] return render_template('rst.html', html=html) @app.route('/feed/<name>') def feed(name): feed = feedparser.parse(FEEDS[name]) return render_template('feed.html', entries=feed.entries) if __name__ == '__main__': from sassutils.wsgi import SassMiddleware app.wsgi_app = SassMiddleware( app.wsgi_app, {'afpy': ('sass', 'static/css', '/static/css')}) app.run(debug=True)
from os import path, getcwd from flask import Flask, render_template, session, redirect, send_from_directory from sassutils.wsgi import SassMiddleware from flask_cas import CAS, login, logout, login_required import logging app = Flask(__name__) app.wsgi_app = SassMiddleware(app.wsgi_app, { 'cas-traefik-auth': ('static/sass', 'static/css', '/static/css') } ) cas = CAS(app, '/cas') app.config['CAS_SERVER'] = "https://cas.k8s.bard.edu" #app.config['CAS_AFTER_LOGIN'] = "******" @app.route("/") def main(): return render_template("index.html") @app.route("/secure") @login_required def secure(): uid = cas.username logging.info(f"CAS object: {cas}") #attributes = cas.attributes logging.info(f"CAS username {uid}") #if attributes: logging.info(f"CAS attributes {attributes}") return render_template("secure.html", cas=cas) @app.route("/logout")