Python-Flask Server

Using the generated stub code from swagger, we ran the code as suggested in the accompanied documentation.

$ cd /PATH/TO/python-flask-server-generated

$ virtualenv -p /usr/local/bin/python3 venv3
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python3/3.6.0_1/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/stealey/Github/irods/swagger-demo/python-flask-server-generated/venv3/bin/python3.6
Also creating executable in /Users/stealey/Github/irods/swagger-demo/python-flask-server-generated/venv3/bin/python
Installing setuptools, pip, wheel...done.

$ source venv3/bin/activate

(venv3)$ pip install -U connexion
Collecting connexion
  Downloading connexion-1.1.10-py3-none-any.whl (1.0MB)
    100% |████████████████████████████████| 1.0MB 982kB/s
Collecting flask>=0.10.1 (from connexion)
  Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
    100% |████████████████████████████████| 92kB 4.2MB/s
Collecting requests>=2.9.1 (from connexion)
  Downloading requests-2.17.3-py2.py3-none-any.whl (87kB)
    100% |████████████████████████████████| 92kB 3.8MB/s
Collecting clickclick>=1.2 (from connexion)
  Using cached clickclick-1.2.1-py3-none-any.whl
Collecting PyYAML>=3.11 (from connexion)
Collecting jsonschema>=2.5.1 (from connexion)
  Using cached jsonschema-2.6.0-py2.py3-none-any.whl
Collecting six>=1.9 (from connexion)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting inflection>=0.3.1 (from connexion)
Collecting typing>=3.6.1 (from connexion)
  Downloading typing-3.6.1.tar.gz (66kB)
    100% |████████████████████████████████| 71kB 3.7MB/s
Collecting swagger-spec-validator>=2.0.2 (from connexion)
Collecting click>=2.0 (from flask>=0.10.1->connexion)
  Using cached click-6.7-py2.py3-none-any.whl
Collecting Jinja2>=2.4 (from flask>=0.10.1->connexion)
  Using cached Jinja2-2.9.6-py2.py3-none-any.whl
Collecting Werkzeug>=0.7 (from flask>=0.10.1->connexion)
  Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB)
    100% |████████████████████████████████| 317kB 2.1MB/s
Collecting itsdangerous>=0.21 (from flask>=0.10.1->connexion)
Collecting urllib3<1.22,>=1.21.1 (from requests>=2.9.1->connexion)
  Using cached urllib3-1.21.1-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.9.1->connexion)
  Downloading chardet-3.0.3-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 3.5MB/s
Collecting idna<2.6,>=2.5 (from requests>=2.9.1->connexion)
  Downloading idna-2.5-py2.py3-none-any.whl (55kB)
    100% |████████████████████████████████| 61kB 5.0MB/s
Collecting certifi>=2017.4.17 (from requests>=2.9.1->connexion)
  Using cached certifi-2017.4.17-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->flask>=0.10.1->connexion)
Building wheels for collected packages: typing
  Running setup.py bdist_wheel for typing ... done
  Stored in directory: /Users/stealey/Library/Caches/pip/wheels/b3/54/d1/d7ad0895b6f57c608afdf3ec5d2339c5d18ffcf2c2e0e0d9aa
Successfully built typing
Installing collected packages: click, MarkupSafe, Jinja2, Werkzeug, itsdangerous, flask, urllib3, chardet, idna, certifi, requests, PyYAML, clickclick, jsonschema, six, inflection, typing, swagger-spec-validator, connexion
Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 PyYAML-3.12 Werkzeug-0.12.2 certifi-2017.4.17 chardet-3.0.3 click-6.7 clickclick-1.2.1 connexion-1.1.10 flask-0.12.2 idna-2.5 inflection-0.3.1 itsdangerous-0.24 jsonschema-2.6.0 requests-2.17.3 six-1.10.0 swagger-spec-validator-2.1.0 typing-3.6.1 urllib3-1.21.1

(venv3)$ python3 app.py
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/ HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/css/typography.css HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/css/reset.css HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/css/screen.css HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/object-assign-pollyfill.js HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/jquery-1.8.0.min.js HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/jquery.slideto.min.js HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/jquery.wiggle.min.js HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/jquery.ba-bbq.min.js HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/handlebars-4.0.5.js HTTP/1.1" 200 -
127.0.0.1 - - [01/Jun/2017 15:48:49] "GET /v1/ui/lib/lodash.min.js HTTP/1.1" 200 -
...

Low and behold we had a running thing!

Exposures API stub

Which looked to populate default values as expected.

Exposures API stub

And this is where the “magic” ends.

From here on out the developer is left to implement the rest of the services as they see fit, starting with a file named: default_controllers.py

def exposures_exposure_type_coordinates_get(exposureType, latitude = None, longitude = None, radius = None, page = None) -> str:
    return 'do some magic!'

def exposures_exposure_type_dates_get(exposureType) -> str:
    return 'do some magic!'

def exposures_exposure_type_scores_get(exposureType, startDate, endDate, exposurePoint, temporalResolution = None, scoreType = None, radius = None, page = None) -> str:
    return 'do some magic!'

def exposures_exposure_type_values_get(exposureType, startDate, endDate, exposurePoint, temporalResolution = None, statisticalType = None, radius = None, page = None) -> str:
    return 'do some magic!'

def exposures_get() -> str:
    return 'do some magic!'

Now we need to go and do some magic!

Package dependencies at this point are ($ pip freeze):

certifi==2017.4.17
chardet==3.0.3
click==6.7
clickclick==1.2.1
connexion==1.1.10
Flask==0.12.2
idna==2.5
inflection==0.3.1
itsdangerous==0.24
Jinja2==2.9.6
jsonschema==2.6.0
MarkupSafe==1.0
PyYAML==3.12
requests==2.17.3
six==1.10.0
swagger-spec-validator==2.1.0
typing==3.6.1
urllib3==1.21.1
Werkzeug==0.12.2