@@ -323,7 +323,111 @@ def create_author():
323323```
324324
325325
326- # # Example 5 from flask-debugtoolbar
326+ # # Example 5 from Flask-Bootstrap
327+ [flask- bootstrap](https:// github.com/ mbr/ flask- bootstrap)
328+ ([PyPI package information](https:// pypi.org/ project/ Flask- Bootstrap/ ))
329+ makes it easier to use the [Bootstrap CSS framework](/ bootstrap- css.html)
330+ in your [Flask](/ flask.html) applications with less boilerplate
331+ code. The project was primarily created by
332+ [Marc Brinkmann @ mbr](https:// github.com/ mbr) and the source code is
333+ open sourced under the
334+ [Apache 2.0 license ](https:// github.com/ mbr/ flask- bootstrap/ blob/ master/ LICENSE ).
335+
336+ [** Flask- Bootstrap / flask_bootstrap / __init__ .py** ](https:// github.com/ mbr/ flask- bootstrap/ blob/ master/ flask_bootstrap/ ./ __init__ .py)
337+
338+ ```python
339+ # __init__.py
340+
341+ import re
342+
343+ ~~ from flask import Blueprint, current_app, url_for
344+
345+ try :
346+ from wtforms.fields import HiddenField
347+ except ImportError :
348+
349+ def is_hidden_field_filter(field):
350+ raise RuntimeError (' WTForms is not installed.' )
351+ else :
352+
353+ def is_hidden_field_filter(field):
354+ return isinstance (field, HiddenField)
355+
356+
357+ from .forms import render_form
358+
359+ __version__ = ' 3.3.7.1.dev1'
360+ BOOTSTRAP_VERSION = re.sub(r ' ^ ( \d + \. \d + \. \d + ) . * ' , r ' \1 ' , __version__ )
361+ JQUERY_VERSION = ' 1.12.4'
362+ HTML5SHIV_VERSION = ' 3.7.3'
363+ RESPONDJS_VERSION = ' 1.4.2'
364+
365+
366+ class CDN(object ):
367+
368+
369+
370+ # # ... source file abbreviated to get to Blueprint examples ...
371+
372+
373+ filename = ' %s .min.%s ' % tuple (filename.rsplit(' .' , 1 ))
374+
375+ cdns = current_app.extensions[' bootstrap' ][' cdns' ]
376+ resource_url = cdns[cdn].get_resource_url(filename)
377+
378+ if resource_url.startswith(' //' ) and config[' BOOTSTRAP_CDN_FORCE_SSL' ]:
379+ resource_url = ' https:%s ' % resource_url
380+
381+ return resource_url
382+
383+
384+ class Bootstrap(object ):
385+ def __init__ (self , app = None ):
386+ if app is not None :
387+ self .init_app(app)
388+
389+ def init_app(self , app):
390+ app.config.setdefault(' BOOTSTRAP_USE_MINIFIED' , True )
391+ app.config.setdefault(' BOOTSTRAP_CDN_FORCE_SSL' , False )
392+
393+ app.config.setdefault(' BOOTSTRAP_QUERYSTRING_REVVING' , True )
394+ app.config.setdefault(' BOOTSTRAP_SERVE_LOCAL' , False )
395+
396+ app.config.setdefault(' BOOTSTRAP_LOCAL_SUBDOMAIN' , None )
397+
398+ ~~ blueprint = Blueprint(
399+ ' bootstrap' ,
400+ __name__ ,
401+ template_folder = ' templates' ,
402+ static_folder = ' static' ,
403+ static_url_path = app.static_url_path + ' /bootstrap' ,
404+ subdomain = app.config[' BOOTSTRAP_LOCAL_SUBDOMAIN' ])
405+
406+ blueprint.add_app_template_filter(render_form)
407+
408+ app.register_blueprint(blueprint)
409+
410+ app.jinja_env.globals[' bootstrap_is_hidden_field' ] = \
411+ is_hidden_field_filter
412+ app.jinja_env.globals[' bootstrap_find_resource' ] = \
413+ bootstrap_find_resource
414+ app.jinja_env.add_extension(' jinja2.ext.do' )
415+
416+ if not hasattr (app, ' extensions' ):
417+ app.extensions = {}
418+
419+ local = StaticCDN(' bootstrap.static' , rev = True )
420+ static = StaticCDN()
421+
422+ def lwrap(cdn, primary = static):
423+
424+
425+ # # ... source file continues with no further Blueprint examples...
426+
427+ ```
428+
429+
430+ # # Example 6 from flask-debugtoolbar
327431[Flask Debug- toolbar](https:// github.com/ flask- debugtoolbar/ flask- debugtoolbar)
328432([documentation](https:// flask- debugtoolbar.readthedocs.io/ en/ latest/ )
329433and
@@ -393,7 +497,7 @@ class DebugToolbarExtension(object):
393497```
394498
395499
396- # # Example 6 from flask-restx
500+ # # Example 7 from flask-restx
397501[Flask RESTX ](https:// github.com/ python- restx/ flask- restx) is an
398502extension that makes it easier to build
399503[RESTful APIs](/ application- programming- interfaces.html) into
@@ -445,7 +549,7 @@ def swagger_static(filename):
445549```
446550
447551
448- # # Example 7 from Flask-WTF
552+ # # Example 8 from Flask-WTF
449553[Flask- WTF ](https:// github.com/ lepture/ flask- wtf)
450554([project documentation](https:// flask- wtf.readthedocs.io/ en/ stable/ )
451555and
@@ -553,7 +657,7 @@ def generate_csrf(secret_key=None, token_key=None):
553657```
554658
555659
556- # # Example 8 from Flask-User
660+ # # Example 9 from Flask-User
557661[Flask- User](https:// github.com/ lingthio/ Flask- User)
558662([PyPI information](https:// pypi.org/ project/ Flask- User/ )
559663and
@@ -660,7 +764,7 @@ class UserManager(UserManager__Settings, UserManager__Utils, UserManager__Views)
660764```
661765
662766
663- # # Example 9 from Flask-VueJs-Template
767+ # # Example 10 from Flask-VueJs-Template
664768[Flask- VueJs- Template](https:// github.com/ gtalarico/ flask- vuejs- template)
665769([demo site](https:// flask- vuejs- template.herokuapp.com/ ))
666770is a minimal [Flask](/ flask.html) boilerplate starter project that
@@ -692,7 +796,7 @@ import os
692796```
693797
694798
695- # # Example 10 from Datadog Flask Example App
799+ # # Example 11 from Datadog Flask Example App
696800The [Datadog Flask example app](https:// github.com/ DataDog/ trace- examples/ tree/ master/ python/ flask)
697801contains many examples of the [Flask](/ flask.html) core functions
698802available to a developer using the [web framework](/ web- frameworks.html).
@@ -739,7 +843,7 @@ def bp_after_request(response):
739843```
740844
741845
742- # # Example 11 from tedivms-flask
846+ # # Example 12 from tedivms-flask
743847[tedivm' s flask starter app](https://github.com/tedivm/tedivms-flask) is a
744848base of [Flask](/ flask.html) code and related projects such as
745849[Celery](/ celery.html) which provides a template to start your own
0 commit comments