Beispiel #1
0
def list():
    """
    Creates a list of all the storess in the stores database.
    :param GET: The function returns a list of storess
    :return:GET returns a list of storess.
    :rtype: Python Dictionary
    """
    from utilities.get_token import token
    stores='None'
    app_id='sample'
    app_secret='test'
    hostip='10.132.0.18'

    get_token = token(app_id,app_secret,hostip)
    token = get_token[0]

    # headers
    headers = {"Content-Type":"application/json", "X-APP-ID":app_id, "X-APP-TOKEN":token}

    # URL for requesting token
    # store_url = 'http://10.132.0.18:8088/stores/'
    store_url = 'http://'+hostip+':8088/stores/'

    # Make request
    stores = requests.get(store_url, headers=headers)
    stores = json.loads(stores.text)
    stores = stores['stores']

    print(stores)
    return render_template('stores/storelist.html', stores=stores)
Beispiel #2
0
def main_select():
    ''' This section to authenticate the user
    '''
    # Do any preprocessing here

    # Pull to submit form variables
    hostip = request.form['hostip']
    app_id = request.form['app_id']
    app_secret = request.form['app_secret']

    # Get token
    result = token(app_id, app_secret, hostip)
    # Check if 200
    if result[1] == 200:
        return render_template('main/main_leaf.html')
    else:
        error = 'FAILED_TO_LOGIN....TRY AGAIN!'
        return render_template('error/error.html', error=error)
Beispiel #3
0
from utilities.get_token import token
import json
import requests

app_id = 'sample'
app_secret = 'test'
hostip = '10.132.0.18'

get_token = token(app_id, app_secret, hostip)
token = get_token[0]
print(token)

# headers
headers = {
    "Content-Type": "application/json",
    "X-APP-ID": app_id,
    "X-APP-TOKEN": token
}

# URL for requesting token
# store_url = 'http://10.132.0.18:8088/stores/'
store_url = 'http://' + hostip + ':8088/stores/'
print(store_url)

# Make request
stores = requests.get(store_url, headers=headers)

print(stores)
print(type(stores))