@@ -10,7 +10,61 @@ meta: Python example code for the Flask class from the flask.app module of the F
1010Flask is a class within the flask.app module of the Flask project.
1111
1212
13- ## Example 1 from Flask AppBuilder
13+ ## Example 1 from Braintree Flask app
14+ [ Braintree's Flask example payments app] ( https://github.com/braintree/braintree_flask_example )
15+ demonstrates how to incorporate this payment provider's
16+ [ API] ( /application-programming-interfaces.html ) into your
17+ [ Flask] ( /flask.html ) [ web application] ( /web-development.html ) .
18+ The code is open sourced under the
19+ [ MIT license] ( https://github.com/braintree/braintree_flask_example/blob/master/LICENSE ) .
20+
21+ [ ** Braintree Flask app / app.py** ] ( https://github.com/braintree/braintree_flask_example/blob/master/././app.py )
22+
23+ ``` python
24+ # app.py
25+ ~~ from flask import Flask, redirect, url_for, render_template, request, flash
26+
27+ import os
28+ from os.path import join, dirname
29+ from dotenv import load_dotenv
30+ import braintree
31+ from gateway import generate_client_token, transact, find_transaction
32+
33+ load_dotenv()
34+
35+ ~~ app = Flask(__name__ )
36+ app.secret_key = os.environ.get(' APP_SECRET_KEY' )
37+
38+ PORT = int (os.environ.get(' PORT' , 4567 ))
39+
40+ TRANSACTION_SUCCESS_STATUSES = [
41+ braintree.Transaction.Status.Authorized,
42+ braintree.Transaction.Status.Authorizing,
43+ braintree.Transaction.Status.Settled,
44+ braintree.Transaction.Status.SettlementConfirmed,
45+ braintree.Transaction.Status.SettlementPending,
46+ braintree.Transaction.Status.Settling,
47+ braintree.Transaction.Status.SubmittedForSettlement
48+ ]
49+
50+ @app.route (' /' , methods = [' GET' ])
51+ def index ():
52+ return redirect(url_for(' new_checkout' ))
53+
54+ @app.route (' /checkouts/new' , methods = [' GET' ])
55+ def new_checkout ():
56+ client_token = generate_client_token()
57+ return render_template(' checkouts/new.html' , client_token = client_token)
58+
59+ @app.route (' /checkouts/<transaction_id>' , methods = [' GET' ])
60+
61+
62+ # # ... source file continues with no further Flask examples...
63+
64+ ```
65+
66+
67+ ## Example 2 from Flask AppBuilder
1468[ Flask-AppBuilder] ( https://github.com/dpgaspar/Flask-AppBuilder )
1569([ documentation] ( https://flask-appbuilder.readthedocs.io/en/latest/ )
1670and
@@ -73,7 +127,7 @@ class OAuthRegistrationRoleTestCase(unittest.TestCase):
73127```
74128
75129
76- ## Example 2 from FlaskBB
130+ ## Example 3 from FlaskBB
77131[ FlaskBB] ( https://github.com/flaskbb/flaskbb )
78132([ project website] ( https://flaskbb.org/ ) ) is a [ Flask] ( /flask.html ) -based
79133forum web application. The web app allows users to chat in an open
@@ -172,7 +226,7 @@ def configure_app(app, config):
172226```
173227
174228
175- ## Example 3 from flask-base
229+ ## Example 4 from flask-base
176230[ flask-base] ( https://github.com/hack4impact/flask-base )
177231([ project documentation] ( http://hack4impact.github.io/flask-base/ ) )
178232provides boilerplate code for new [ Flask] ( /flask.html ) web apps.
@@ -251,7 +305,7 @@ def create_app(config):
251305```
252306
253307
254- ## Example 4 from flask-bookshelf
308+ ## Example 5 from flask-bookshelf
255309[ flask-bookshelf] ( https://github.com/damyanbogoev/flask-bookshelf ) is the
256310example [ Flask] ( /flask.html ) application that developers create when
257311going through
@@ -303,7 +357,7 @@ def get_lang_code(endpoint, values):
303357```
304358
305359
306- ## Example 5 from flaskex
360+ ## Example 6 from flaskex
307361[ Flaskex] ( https://github.com/anfederico/Flaskex ) is a working example
308362[ Flask] ( /flask.html ) web application intended as a base to build your
309363own applications upon. The application comes with pre-built sign up, log in
@@ -356,7 +410,7 @@ def logout():
356410```
357411
358412
359- ## Example 6 from Flask-HTTPAuth
413+ ## Example 7 from Flask-HTTPAuth
360414[ Flask-HTTPAuth] ( https://github.com/miguelgrinberg/Flask-HTTPAuth )
361415([ documentation] ( https://flask-httpauth.readthedocs.io/en/latest/ )
362416and
@@ -412,7 +466,7 @@ class HTTPAuthTestCase(unittest.TestCase):
412466```
413467
414468
415- ## Example 7 from flask-phone-input
469+ ## Example 8 from flask-phone-input
416470[ flask-phone-input] ( https://github.com/miguelgrinberg/flask-phone-input )
417471is an example application that ties together the
418472[ intTellInput.js] ( https://github.com/jackocnr/intl-tel-input )
@@ -464,7 +518,7 @@ def index():
464518```
465519
466520
467- ## Example 8 from flaskSaaS
521+ ## Example 9 from flaskSaaS
468522[ flaskSaas] ( https://github.com/alectrocute/flaskSaaS ) is a boilerplate
469523starter project to build a software-as-a-service (SaaS) web application
470524in [ Flask] ( /flask.html ) , with [ Stripe] ( /stripe.html ) for billing. The
@@ -513,7 +567,7 @@ from app.models import User
513567```
514568
515569
516- ## Example 9 from Flask-SocketIO
570+ ## Example 10 from Flask-SocketIO
517571[ Flask-SocketIO] ( https://github.com/miguelgrinberg/Flask-SocketIO )
518572([ PyPI package information] ( https://pypi.org/project/Flask-SocketIO/ ) ,
519573[ official tutorial] ( https://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent )
@@ -624,7 +678,7 @@ if __name__ == '__main__':
624678```
625679
626680
627- ## Example 10 from Flask-User
681+ ## Example 11 from Flask-User
628682[ Flask-User] ( https://github.com/lingthio/Flask-User )
629683([ PyPI information] ( https://pypi.org/project/Flask-User/ )
630684and
@@ -707,7 +761,7 @@ class UserManager(UserManager__Settings, UserManager__Utils, UserManager__Views)
707761```
708762
709763
710- ## Example 11 from Flask-VueJs-Template
764+ ## Example 12 from Flask-VueJs-Template
711765[ Flask-VueJs-Template] ( https://github.com/gtalarico/flask-vuejs-template )
712766([ demo site] ( https://flask-vuejs-template.herokuapp.com/ ) )
713767is a minimal [ Flask] ( /flask.html ) boilerplate starter project that
@@ -748,7 +802,7 @@ def index_client():
748802```
749803
750804
751- ## Example 12 from Flasky
805+ ## Example 13 from Flasky
752806[ Flasky] ( https://github.com/miguelgrinberg/flasky ) is a wonderful
753807example application by
754808[ Miguel Grinberg] ( https://github.com/miguelgrinberg ) that he builds
@@ -812,7 +866,7 @@ def create_app(config_name):
812866```
813867
814868
815- ## Example 13 from Datadog Flask Example App
869+ ## Example 14 from Datadog Flask Example App
816870The [ Datadog Flask example app] ( https://github.com/DataDog/trace-examples/tree/master/python/flask )
817871contains many examples of the [ Flask] ( /flask.html ) core functions
818872available to a developer using the [ web framework] ( /web-frameworks.html ) .
@@ -873,7 +927,7 @@ def before_request():
873927```
874928
875929
876- ## Example 14 from keras-flask-deploy-webapp
930+ ## Example 15 from keras-flask-deploy-webapp
877931The
878932[ keras-flask-deploy-webapp] ( https://github.com/mtobeiyf/keras-flask-deploy-webapp )
879933project combines the [ Flask] ( /flask.html ) [ web framework] ( /web-frameworks.html )
@@ -937,7 +991,7 @@ def model_predict(img, model):
937991```
938992
939993
940- ## Example 15 from sandman2
994+ ## Example 16 from sandman2
941995[ sandman2] ( https://github.com/jeffknupp/sandman2 )
942996([ project documentation] ( https://sandman2.readthedocs.io/en/latest/ )
943997and
@@ -1018,7 +1072,7 @@ def get_app(
10181072```
10191073
10201074
1021- ## Example 16 from tedivms-flask
1075+ ## Example 17 from tedivms-flask
10221076[ tedivm's flask starter app] ( https://github.com/tedivm/tedivms-flask ) is a
10231077base of [ Flask] ( /flask.html ) code and related projects such as
10241078[ Celery] ( /celery.html ) which provides a template to start your own
@@ -1147,7 +1201,7 @@ def create_app(extra_config_settings={}):
11471201```
11481202
11491203
1150- ## Example 17 from trape
1204+ ## Example 18 from trape
11511205[ trape] ( https://github.com/jofpin/trape ) is a research tool for tracking
11521206people's activities that are logged digitally. The tool uses
11531207[ Flask] ( /flask.html ) to create a web front end to view aggregated data
0 commit comments