gakonst

Untitled

Feb 24th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #!/usr/bin/env python from datetime import datetime
  2. from flask import Flask, jsonify, request, render_template
  3. import requests
  4. import json
  5.  
  6. app = Flask(__name__)
  7.  
  8. app.keyConfig = {'clientID': '303be398', 'clientSecret':'7560b20d30353182500fee69178333e1'}
  9. session = requests.Session()
  10.  
  11. @app.route('/api/login', methods = ['GET'])
  12. def login():
  13. response = session.post('https://sso.sbb.ch/auth/realms/SBB_Public/protocol/openid-connect/token', data=json.dumps({
  14. 'grant_type': 'client_credentials',
  15. 'client_id': app.keyConfig['clientID'],
  16. 'client_secret': app.keyConfig['clientSecret']
  17. }
  18. )
  19. )
  20. print(response.text)
  21. print("Running job")
  22. return jsonify('Running job')
  23.  
  24.  
  25. @app.route('/api/homepage', methods = ['GET'])
  26. def get_homepage():
  27. return jsonify('Hello world')
  28.  
  29. @app.route('/api/keywords', methods = ['POST'])
  30. def get_maps():
  31. params = request.form # get form data
  32. keyword = params['keyword']
  33. radius = params['radius'] or 500000
  34. d = gmaps.places_autocomplete_query(keyword, location=SWISS_COORD, radius=radius)
  35. # d = gmaps.places_nearby(location=SWISS_COORD, keyword=keyword)
  36. return jsonify(d)
  37.  
  38. if __name__ == '__main__':
  39. app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment