Esempio n. 1
0
def idSearch(loc_id):
    response = requests.get(openDataURL)
    data = response.json()
    if loc_id > 0 and loc_id - 1 <= len(data['features']):
        return jsonify(data['features'][loc_id - 1])
    else:
        return not_found()
Esempio n. 2
0
def idSearch(park_id):
    response = requests.get(openDataURL)
    data = response.json()
    if park_id > 0 and park_id - 1 <= len(data):
        return jsonify(data[park_id - 1])
    else:
        return not_found()
Esempio n. 3
0
def nameSearch(name):
    response = requests.get(openDataURL)
    data = response.json()
    resList = []
    for item in data['features']:
        if name in item['properties']['name']:
            resList.append(item)

    if len(resList) == 0:
        return not_found()
    else:
        return jsonify(resList)
Esempio n. 4
0
def update_report():
    cursor = mysql.connection.cursor()
    try:
        _id = request.args.get('id')
        _text = request.args.get('text')
        _image = request.args.get('image')
        _userTable_id = request.args.get('userTable_id')
        if _id and _text and _image and _userTable_id:
            sql = 'UPDATE reporttable SET text = %s, image = %s, userTable_id = %s WHERE id = %s'
            data = (_text, _image, _userTable_id, _id)
            cursor.execute(sql, data)
            cursor.connection.commit()
            resp = jsonify('Done!')
            resp.status_code = 201
            return resp
        else:
            return not_found()
    except Exception as e:
        print(e)
    finally:
        cursor.close()
Esempio n. 5
0
def create_report():
    cursor = mysql.connection.cursor()
    try:
        _id = request.args.get('id')
        _text = request.args.get('text')
        _image = request.args.get('image')
        _userTable_id = request.args.get('userTable_id')
        if _id and _text and _image and _userTable_id:
            sql = 'INSERT INTO reporttable(text,image,userTable_id) VALUES(%s,%s,%s)'
            data = (_text, _image, _userTable_id)
            cursor.execute(sql, data)
            cursor.connection.commit()
            resp = jsonify('Done!')
            resp.status_code = 201
            return resp
        else:
            return not_found()
    except Exception as e:
        print(e)
    finally:
        cursor.close()
def update_user():
    cursor = mysql.connection.cursor()
    try:
        _id = request.args.get('id')
        _nickname = request.args.get('nickname')
        _name = request.args.get('name')
        _email = request.args.get('email')
        _adminFlag = request.args.get('adminFlag')
        if _id and _nickname and _name and _email and _adminFlag:
            sql = 'UPDATE usertable SET nickname = %s, name = %s, email = %s, adminFlag = %s WHERE id = %s'
            data = (_nickname, _name, _email, _adminFlag, _id)
            cursor.execute(sql, data)
            cursor.connection.commit()
            resp = jsonify('Done!')
            resp.status_code = 201
            return resp
        else:
            return not_found()
    except Exception as e:
        print(e)
    finally:
        cursor.close()
def create_user():
    cursor = mysql.connection.cursor()
    try:
        _id = request.args.get('id')
        _nickname = request.args.get('nickname')
        _name = request.args.get('name')
        _email = request.args.get('email')
        _adminFlag = request.args.get('adminFlag')
        if _id and _nickname and _name and _email and _adminFlag:
            sql = 'INSERT INTO usertable(id,nickname,name,email,adminFlag) VALUES(%s,%s,%s,%s,%s)'
            data = (_id, _nickname, _name, _email, _adminFlag)
            cursor.execute(sql, data)
            cursor.connection.commit()
            resp = jsonify('Done!')
            resp.status_code = 201
            return resp
        else:
            return not_found()
    except Exception as e:
        print(e)
    finally:
        cursor.close()