Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python from datetime import datetime
- from flask import Flask, jsonify, request, render_template
- import requests
- import json
- app = Flask(__name__)
- app.keyConfig = {'clientID': '303be398', 'clientSecret':'7560b20d30353182500fee69178333e1'}
- session = requests.Session()
- @app.route('/api/login', methods = ['GET'])
- def login():
- response = session.post('https://sso.sbb.ch/auth/realms/SBB_Public/protocol/openid-connect/token', data=json.dumps({
- 'grant_type': 'client_credentials',
- 'client_id': app.keyConfig['clientID'],
- 'client_secret': app.keyConfig['clientSecret']
- }
- )
- )
- print(response.text)
- print("Running job")
- return jsonify('Running job')
- @app.route('/api/homepage', methods = ['GET'])
- def get_homepage():
- return jsonify('Hello world')
- @app.route('/api/keywords', methods = ['POST'])
- def get_maps():
- params = request.form # get form data
- keyword = params['keyword']
- radius = params['radius'] or 500000
- d = gmaps.places_autocomplete_query(keyword, location=SWISS_COORD, radius=radius)
- # d = gmaps.places_nearby(location=SWISS_COORD, keyword=keyword)
- return jsonify(d)
- if __name__ == '__main__':
- app.run(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment