@@ -356,7 +356,63 @@ def logout():
356356```
357357
358358
359- ## Example 6 from flask-phone-input
359+ ## Example 6 from Flask-HTTPAuth
360+ [ Flask-HTTPAuth] ( https://github.com/miguelgrinberg/Flask-HTTPAuth )
361+ ([ documentation] ( https://flask-httpauth.readthedocs.io/en/latest/ )
362+ and
363+ [ PyPI package information] ( https://pypi.org/project/Flask-HTTPAuth/ ) )
364+ is a [ Flask] ( /flask.html ) framework extension that creates
365+ Basic and Digest HTTP authentication for routes. This project
366+ is primarily built and maintained by
367+ [ Miguel Grinberg] ( https://blog.miguelgrinberg.com/ ) . It is provided
368+ as open source under the
369+ [ MIT license] ( https://github.com/miguelgrinberg/Flask-HTTPAuth/blob/master/LICENSE ) .
370+
371+ [ ** Flask-HTTPAuth / tests / test_basic_get_password.py** ] ( https://github.com/miguelgrinberg/Flask-HTTPAuth/blob/master/./tests/test_basic_get_password.py )
372+
373+ ``` python
374+ # test_basic_get_password.py
375+ import unittest
376+ import base64
377+ ~~ from flask import Flask
378+ from flask_httpauth import HTTPBasicAuth
379+
380+
381+ class HTTPAuthTestCase (unittest .TestCase ):
382+ def setUp (self ):
383+ ~~ app = Flask(__name__ )
384+ app.config[' SECRET_KEY' ] = ' my secret'
385+
386+ basic_auth = HTTPBasicAuth()
387+
388+ @basic_auth.get_password
389+ def get_basic_password (username ):
390+ if username == ' john' :
391+ return ' hello'
392+ elif username == ' susan' :
393+ return ' bye'
394+ else :
395+ return None
396+
397+ @app.route (' /' )
398+ def index ():
399+ return ' index'
400+
401+ @app.route (' /basic' )
402+ @basic_auth.login_required
403+ def basic_auth_route ():
404+ return ' basic_auth:' + basic_auth.username()
405+
406+ self .app = app
407+ self .basic_auth = basic_auth
408+
409+
410+ # # ... source file continues with no further Flask examples...
411+
412+ ```
413+
414+
415+ ## Example 7 from flask-phone-input
360416[ flask-phone-input] ( https://github.com/miguelgrinberg/flask-phone-input )
361417is an example application that ties together the
362418[ intTellInput.js] ( https://github.com/jackocnr/intl-tel-input )
@@ -408,7 +464,7 @@ def index():
408464```
409465
410466
411- ## Example 7 from flaskSaaS
467+ ## Example 8 from flaskSaaS
412468[ flaskSaas] ( https://github.com/alectrocute/flaskSaaS ) is a boilerplate
413469starter project to build a software-as-a-service (SaaS) web application
414470in [ Flask] ( /flask.html ) , with [ Stripe] ( /stripe.html ) for billing. The
@@ -457,7 +513,7 @@ from app.models import User
457513```
458514
459515
460- ## Example 8 from Flask-SocketIO
516+ ## Example 9 from Flask-SocketIO
461517[ Flask-SocketIO] ( https://github.com/miguelgrinberg/Flask-SocketIO )
462518([ PyPI package information] ( https://pypi.org/project/Flask-SocketIO/ ) ,
463519[ official tutorial] ( https://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent )
@@ -568,7 +624,7 @@ if __name__ == '__main__':
568624```
569625
570626
571- ## Example 9 from Flask-User
627+ ## Example 10 from Flask-User
572628[ Flask-User] ( https://github.com/lingthio/Flask-User )
573629([ PyPI information] ( https://pypi.org/project/Flask-User/ )
574630and
@@ -651,7 +707,7 @@ class UserManager(UserManager__Settings, UserManager__Utils, UserManager__Views)
651707```
652708
653709
654- ## Example 10 from Flask-VueJs-Template
710+ ## Example 11 from Flask-VueJs-Template
655711[ Flask-VueJs-Template] ( https://github.com/gtalarico/flask-vuejs-template )
656712([ demo site] ( https://flask-vuejs-template.herokuapp.com/ ) )
657713is a minimal [ Flask] ( /flask.html ) boilerplate starter project that
@@ -692,7 +748,7 @@ def index_client():
692748```
693749
694750
695- ## Example 11 from Flasky
751+ ## Example 12 from Flasky
696752[ Flasky] ( https://github.com/miguelgrinberg/flasky ) is a wonderful
697753example application by
698754[ Miguel Grinberg] ( https://github.com/miguelgrinberg ) that he builds
@@ -756,7 +812,7 @@ def create_app(config_name):
756812```
757813
758814
759- ## Example 12 from Datadog Flask Example App
815+ ## Example 13 from Datadog Flask Example App
760816The [ Datadog Flask example app] ( https://github.com/DataDog/trace-examples/tree/master/python/flask )
761817contains many examples of the [ Flask] ( /flask.html ) core functions
762818available to a developer using the [ web framework] ( /web-frameworks.html ) .
@@ -817,7 +873,71 @@ def before_request():
817873```
818874
819875
820- ## Example 13 from sandman2
876+ ## Example 14 from keras-flask-deploy-webapp
877+ The
878+ [ keras-flask-deploy-webapp] ( https://github.com/mtobeiyf/keras-flask-deploy-webapp )
879+ project combines the [ Flask] ( /flask.html ) [ web framework] ( /web-frameworks.html )
880+ with the [ Keras deep learning library] ( https://keras.io/ ) to provide
881+ an example image classifier that is easy to [ deploy] ( /deployment.html ) .
882+ The application can be quckly run in a [ Docker] ( /docker.html ) container
883+ on your local development environment. The project is licensed under the
884+ [ GNU General Public License v3.0] ( https://github.com/mtobeiyf/keras-flask-deploy-webapp/blob/master/LICENSE ) .
885+
886+ [ ** keras-flask-deploy-webapp / app.py** ] ( https://github.com/mtobeiyf/keras-flask-deploy-webapp/blob/master/././app.py )
887+
888+ ``` python
889+ # app.py
890+ import os
891+ import sys
892+
893+ ~~ from flask import Flask, redirect, url_for, request, render_template, Response, jsonify, redirect
894+ from werkzeug.utils import secure_filename
895+ from gevent.pywsgi import WSGIServer
896+
897+ import tensorflow as tf
898+ from tensorflow import keras
899+
900+ from tensorflow.keras.applications.imagenet_utils import preprocess_input, decode_predictions
901+ from tensorflow.keras.models import load_model
902+ from tensorflow.keras.preprocessing import image
903+
904+ import numpy as np
905+ from util import base64_to_pil
906+
907+
908+ ~~ app = Flask(__name__ )
909+
910+
911+ from keras.applications.mobilenet_v2 import MobileNetV2
912+ model = MobileNetV2(weights = ' imagenet' )
913+
914+ print (' Model loaded. Check http://127.0.0.1:5000/' )
915+
916+
917+ MODEL_PATH = ' models/your_model.h5'
918+
919+
920+
921+ def model_predict (img , model ):
922+ img = img.resize((224 , 224 ))
923+
924+ x = image.img_to_array(img)
925+ x = np.expand_dims(x, axis = 0 )
926+
927+ x = preprocess_input(x, mode = ' tf' )
928+
929+ preds = model.predict(x)
930+ return preds
931+
932+
933+
934+
935+ # # ... source file continues with no further Flask examples...
936+
937+ ```
938+
939+
940+ ## Example 15 from sandman2
821941[ sandman2] ( https://github.com/jeffknupp/sandman2 )
822942([ project documentation] ( https://sandman2.readthedocs.io/en/latest/ )
823943and
@@ -898,7 +1018,7 @@ def get_app(
8981018```
8991019
9001020
901- ## Example 14 from tedivms-flask
1021+ ## Example 16 from tedivms-flask
9021022[ tedivm's flask starter app] ( https://github.com/tedivm/tedivms-flask ) is a
9031023base of [ Flask] ( /flask.html ) code and related projects such as
9041024[ Celery] ( /celery.html ) which provides a template to start your own
0 commit comments