Skip to content

Commit

Permalink
#12 run getdiff as api call
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuku Man committed Apr 9, 2019
1 parent b1125b6 commit ed9a412
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
6 changes: 6 additions & 0 deletions webAPI/GPS_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from getDisplacement import getDisplacement
from getVelocities import getVelocities
from getModel import getModel
from getDiff import getDiff

from copy import deepcopy

Expand Down Expand Up @@ -60,6 +61,11 @@ def getURLprefix():

return urlprefix

def run_getDiff(args):
""" run getDiff function """

return "True"

def generateKML(args):
""" main function to generate KMLs """

Expand Down
31 changes: 22 additions & 9 deletions webAPI/GPS_service_API.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
GPS_service_API.py
-- a minimum flask api wrapper
GPS_service_API.py
-- a minimum flask api wrapper
$export FLASK_APP=GPS_service.py
$export FLASK_APP=GPS_service.py
$export FLASK_DEBUG=1
$python3 -m flask run
Expand All @@ -15,7 +15,9 @@
import json
from flask import Flask
from flask import request
from flask import Response
from GPS_service import generateKML
from GPS_service import run_getDiff

app = Flask(__name__)

Expand All @@ -32,14 +34,25 @@ def test():
"""generate kml"""
@app.route("/gpsservice/kml")
def kml():
""" main function to generate KMLs"""
args = request.args
""" main function to generate KMLs"""
args = request.args

# assume everything is right
result = generateKML(args)
# assume everything is right
try:
function = args['function']
except KeyError:
return Response("bad request",status=400)

return result
result = ""

if not function == "getDiff":
result = generateKML(args)

if function == "getDiff":
result = run_getDiff(args)

return result

if __name__ == "__main__":
pass
Expand Down
6 changes: 3 additions & 3 deletions webAPI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ getDisplacemnet:[output,lat,lon,width,height,epoch1,epoch2][scale,ref,eon,mon,dw
getModel:[output,lat,lon,width,height,epoch1,epoch2][scale,ref,eon,mon,vabs]

sample call:
http://192.168.59.130:5000/gpsservice/kml?function=getPostseismic&lat=33&lon=-115&width=2&height=2&epoch=2010-04-08
http://172.16.104.138:5000/gpsservice/kml?function=getvelocities&lat=33.1&lon=-115.1&width=2&height=2&epoch=&epoch1=&epoch2=&scale=&ref=&ct=&pt=&dwin1=&dwin2=&prefix=&mon=false&eon=false&vabs=false

output:
{"folder": "kml1867", "urlprefix": "http://", "results": ["postseismic.txt", "postseismic.kml"]}
http://192.168.59.130:5000/gpsservice/kml?function=getvelocities&lat=33&lon=-115&width=2&height=2&epoch=&epoch1=&epoch2=&scale=&ref=WMDG&ct=&pt=&dwin1=&dwin2=&mon=false&eon=false&vabs=true
{"results": ["velocity_vertical.kml", "velocity_table.txt", "velocity_horizontal.kml"], "urlprefix": "http://172.16.104.138:5000/static/", "folder": "kml096320193009113018", "urls": ["http://172.16.104.138:5000/static/kml096320193009113018/velocity_vertical.kml", "http://172.16.104.138:5000/static/kml096320193009113018/velocity_table.txt", "http://172.16.104.138:5000/static/kml096320193009113018/velocity_horizontal.kml"]}

Add a new non-required parameter:
-- add para to nonrequired list
Expand Down

0 comments on commit ed9a412

Please sign in to comment.