Skip to content

Instantly share code, notes, and snippets.

@mddub
Created June 4, 2016 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mddub/f7245472afe44521b56dce6a35b5c4b5 to your computer and use it in GitHub Desktop.
Save mddub/f7245472afe44521b56dce6a35b5c4b5 to your computer and use it in GitHub Desktop.
import json
import random
from flask import Flask, request
app = Flask(__name__)
x = 0
@app.route('/ShareWebServices/Services/General/LoginPublisherAccountByName', methods=['post'])
def login():
token = ''.join(random.choice('abcdefghijklm') for _ in range(10))
print "token:", token
return json.dumps(token)
@app.route('/ShareWebServices/Services/Publisher/ReadPublisherLatestGlucoseValues', methods=['post'])
def latest():
global x
x += 1
print x
if x % 3 == 0:
return json.dumps([{'Value': 30, 'Trend': 4, 'WT': '/Date(1462404576000)/'}])
else:
return json.dumps({'Code': 'SessionNotValid'})
if __name__ == "__main__":
app.run(
debug=True,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment