Пример #1
0
def login():
    if session.get("fromPredict"):
        session["fromPredict"] = False
    elif session.get("prediction"):
        session.pop("prediction")
        session.pop("confidence")
        if session.get("imageURL"):
            session.pop("imageURL")
        # if(os.path.exists(session.get('segmentImageURL'))):
        #     os.remove(session.get('segmentImageURL'))
        #     print("File Removed!")

    if not session.get("logged_in"):
        form = forms.LoginForm(request.form)
        if request.method == "POST":
            username = request.form["username"].lower()
            password = request.form["password"]
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session["logged_in"] = True
                    session["username"] = username
                    return json.dumps({"status": "Login successful"})
                return json.dumps({"status": "Invalid user/pass"})
            return json.dumps({"status": "Both fields required"})
        return render_template("login.html", form=form)
    user = helpers.get_user()
    return render_template("home.html", user=user)
Пример #2
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    fxpairselected = fxpairs[0]
    timeframeselected = timeframes[0]

    #CHECK SUBSCRIPTION
    if user.expiry:
        date = user.expiry
    else:
        date = "0001-01-01"
    return render_template('home.html',
                           user=user,
                           fxpairs=fxpairs,
                           fxpairselected=fxpairselected,
                           timeframes=timeframes,
                           timeframeselected=timeframeselected,
                           date=date,
                           key=stripe_keys['publishable_key'])
Пример #3
0
def login_api():
    if not session.get('logged_in'):
        if request.method == 'POST':
            username = request.form.get("username")
            password = request.form.get("password")
            if helpers.credentials_valid(username, password):
                session['logged_in'] = True
                session['username'] = username
                return json.dumps({'status': 'Login successful', 'code': 201})
            return json.dumps({'status': 'Invalid user/pass', 'code': 401})
        return json.dumps({'status': 'Accept only Post', 'code': 402})
    return json.dumps({'status': 'user logged in', 'code': 202})
Пример #4
0
def recognize_image():

    username = request.headers['ID']
    password = request.headers['Authorization']
    email = request.headers['email']
    paymentflag = request.headers['flag']

    if helpers.credentials_valid(username, password, paymentflag):

        #img_url = request.get_json()['img_url']
        r = request
        # convert string of image data to uint8
        nparr = np.fromstring(r.data, np.uint8)
        # decode image
        img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
        X = []

        # prepare image for prediction

        #img = cv2.imread(img_url)
        if img is not None:
            img = skimage.transform.resize(img, (150, 150, 3))
            img = np.asarray(img)
            X.append(img)

        X_pred = np.asarray(X)

        # predict
        prediction_array = model.predict(X_pred)
        pred = np.argmax(prediction_array, axis=1)

        # prepare api response
        class_names = ['NORMAL', 'PNEUMONIA']
        result = {
            "prediction": class_names[np.argmax(prediction_array)],
            "confidence": '{:2.0f}%'.format(100 * np.max(prediction_array))
        }

        return jsonify(isError=False,
                       message="Success",
                       statusCode=200,
                       data=result), 200

    result = {
        "prediction": 'Authentication Invalid',
        "confidence": 'Authentication Invalid'
    }

    return jsonify(isError=True, message="Failed", statusCode=400,
                   data=result), 400
Пример #5
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if username != "" and password != "":
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return redirect(url_for('homepage'))
                return render_template('login.html', error="Invalid username or password.")
            return render_template('login.html', error="Fill in both fields.")
        return render_template('login.html', form=form)
    return redirect(url_for('homepage'))
Пример #6
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    return render_template('home.html', user=user)
Пример #7
0
def login():    

    if not session.get('logged_in'):

        # user not logged in

        form = forms.LoginForm(request.form)

        if request.method == 'POST':

            username = request.form['username'].lower()

            password = request.form['password']

            if form.validate():

                if helpers.credentials_valid(username, password):

                    session['logged_in'] = True

                    session['username'] = username

                    return json.dumps({'status': 'Login successful'})

                return json.dumps({'status': 'Invalid user/pass'})

            return json.dumps({'status': 'Both fields required'})

        return render_template('login.html', form=form)

    # user logged in    

    user = helpers.get_user()

    if user.payed == 0: 

    # user must pay    

        return render_template('payment.html', pub_key=pub_key)

    else:

    # user paid already   

        #return render_template('product.html', user=user)

        return render_template('home.html', user=user)
Пример #8
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)

    image_names = os.listdir('static/PeopleNotWearingMask')
    user = helpers.get_user()
    return render_template('home.html', user=user, image_names=image_names, curr = customers.customer.capacity)
Пример #9
0
def login():
    '''
    Login check
    '''
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    '''
    Return memems from HDFS

    Common.py is our core libray written by ourselves to use SparkSQL or do inner-text dection 
    Common.py can be seen in .../Flaskex/
    '''

    sskey = ""
    if 'keyword' in session:
        sskey = session["keyword"]
    simages = ""
    if 'imagePath' in session:
        if session['imagePath'] != "":
            imagePath = session['imagePath']
            print(imagePath)
            if (sskey == ""):
                return render_template("home.html", user=user)
            commonF = Common()
            # Common is written by ourselves to run SparkSQL
            simages = commonF.sprkSQLReadDFtoList(imagePath, sskey)
            # sprkSQLReadDFtoList is to get images from hdfs using SparkSQL
            sskey = "You are searching " + sskey
    return render_template('home.html',
                           user=user,
                           searchkey=sskey,
                           hists=simages)
def login():
    if not session.get('logged_in'):
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if forms.LoginForm(request.form).validate():

                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    session['email'] = email
                    return jsonify({'status': 'Login successful'})
                else:
                    return jsonify({'status': 'Invalid username/password'})

            else:
                return jsonify({'status': 'Both fields required'})
    else:
        return render_template('home.html')
Пример #11
0
def login():
    form = forms.LoginForm(request.form)

    if request.method == 'POST':
        username = request.form['username'].lower()
        password = request.form['password']
        if form.validate():
            if helpers.credentials_valid(username, password):
                session['logged_in'] = True
                session['username'] = username
                user = helpers.get_user()
                return render_template('home.html', user=user), 200

            else:
                flash('Wrong Username or Password', 'error')
                return render_template("out_facing/login.html"), 401

        else:
            flash('Both fields required', 'error')
            return render_template("out_facing/login.html"), 400

    return render_template("out_facing/login.html")
Пример #12
0
def login():
    if not session.get('logged_in'):
        form = forms.LoginForm(request.form)
        if request.method == 'POST':
            username = request.form['username'].lower()
            password = request.form['password']
            if form.validate():
                if helpers.credentials_valid(username, password):
                    session['logged_in'] = True
                    session['username'] = username
                    return json.dumps({'status': 'Login successful'})
                return json.dumps({'status': 'Invalid user/pass'})
            return json.dumps({'status': 'Both fields required'})
        return render_template('login.html', form=form)
    user = helpers.get_user()
    user.active = user.payment == helpers.payment_token()
    user.key = stripe_keys['publishable_key']
    if user.active:
        disabled = ''
    else:
        disabled = 'disabled'

    return render_template('home.html', user=user, disabled=disabled)