def login(request): data = request.get_json() username = data[ACCOUNT_LOGIN_USERNAME] password = data[ACCOUNT_LOGIN_PASSWORD] if login_to_api(username, password): return respond(200) return respond(460)
def return_bike(request): data = request.get_json() bike_no = data[BIKE_NUMBER] station = data[STATION_NUMBER] comment = data[COMMENT] response = post({'action': 'return', 'bike_no': bike_no, 'new_return_street': '', 'return_place_id': station, 'city_id': session[SESSION_CITY], 'finallat': '', 'finallng': '', 'end_street2': comment}) return respond(401)
def history(): account_history = get_history() if account_history: return respond(200, account_history=account_history) return respond(401)
def logged(): if SESSION_AUTH_TOKEN in session: return respond(200) return respond(401)
def logout(): session.clear() return respond(200)
def rent_bike(request): data = request.get_json() bike_no = data[BIKE_NUMBER] response = post({'action': 'look_up', 'bike_no': bike_no, 'quick': 1}) return respond(401)
def list_bikes(): response = get() return respond(401)
def unlock(request): data = request.get_json() bike_no = data[BIKE_NUMBER] response = post({'action': 'look_up', 'bike_no': bike_no, 'open_rack': 1}) return respond(401)
def get_all(): client = pymongo.MongoClient() db = client['bikeathand'] cursor = db.stations.find({}, {'_id': False}) stations = json.loads(json_util.dumps(cursor)) return respond(200, stations=stations)