Add crossway api for cars
This commit is contained in:
parent
70d7189f4a
commit
c0a87c7700
@ -1,17 +1,32 @@
|
|||||||
|
import requests
|
||||||
|
from bson import json_util
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
|
ENTITY_IDENT_URL = 'http://entityident:5002/api/v1/resources/'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def hello_world():
|
def hello_world():
|
||||||
return 'Hello World'
|
return 'Hello World'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api1')
|
@app.route('/api/v1/resources/cars', methods=['GET'])
|
||||||
def api1():
|
def get_cars():
|
||||||
return 'api1'
|
|
||||||
|
try:
|
||||||
|
response = requests.get(ENTITY_IDENT_URL + 'cars')
|
||||||
|
cars = response.json()['cursor']
|
||||||
|
|
||||||
|
except requests.exceptions.ConnectionError as e:
|
||||||
|
print("Is the entity_ident_server running and reachable?")
|
||||||
|
raise e
|
||||||
|
|
||||||
|
return json_util.dumps({'cursor': cars})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/api2')
|
@app.route('/api2')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user