Using Flask to build a Senasoft example.
Integration with Flask-restplus, Flask-Cors, Flask-Testing, Flask-SQLalchemy,and Flask-OAuth extensions.
-
Restful: Flask-restplus
-
SQL ORM: Flask-SQLalchemy
-
Testing: Flask-Testing
-
OAuth: Flask-OAuth
-
ESDAO: elasticsearch , elasticsearch-dsl
Install with pip:
$ pip install -r requirements.txt
.
|ββββββapp/
| |ββββ__init__.py
| |ββββapi/
| | |ββββ__init__.py
| | |ββββcve/
| | |ββββuser/
| | |ββββoauth/
| |ββββββconfig.Development.cfg
| |ββββββconfig.Production.cfg
| |ββββββconfig.Testing.cfg
| |ββββdao/
| |ββββmodel/
| |ββββoauth/
| |ββββutil/
|ββββββrun.py
|ββββββtests/
app = Flask(__name__)
app.config['DEBUG'] = True
app = Flask(__name__ )
app.config.from_pyfile('config.Development.cfg')
##Flask settings
DEBUG = True # True/False
TESTING = False
....
SERVER_NAME: the name and port number of the server.
JSON_SORT_KEYS : By default Flask will serialize JSON objects in a way that the keys are ordered.
add your client_id
and client_secret
into config file.
add your ES host
and ES port
into config file
$ python webapp/run.py
In flask, Default port is 5000
Swagger document page: http://127.0.0.1:5000/
$ docker build -t flask-example .
$ docker run -p 5000:5000 --name flask-example flask-example
In image building, the webapp folder will also add into the image
Offical Website
Tutorial
- Version 2.0 : add SQL ORM extension: FLASK-SQLAlchemy
- Version 1.1 : update nosetest
- Version 1.0 : basic flask-example with Flask-Restplus, Flask-Tesintg