示例#1
0
def run():
    # Script for simulating user interaction
    try:
        databaseOps.intialDatabaseCreation()
    except:
        pass
    username = "******"
    password = "******"
    FirstName = "Kate"
    LastName = "Newman"
    PhoneNumber = "928353461"
    Address = "1789 S Failing Finals ST Flagstaff AZ 86001"
    Email = "*****@*****.**"
    qrStirng = f"Name: {FirstName} {LastName} \nPhoneNumber: {PhoneNumber}\nAddress: {Address}\nEmail: {Email}"
    userID = databaseOps.getUserID(username)
    accountBackEnd.add_account_to_data_base(username, password)
    databaseOps.addDatabaseEntry(userID, FirstName, LastName, PhoneNumber,
                                 Address, Email)
    databaseOps.addQrDataEntry(userID, username, qrStirng)
示例#2
0
        return redirect(url_for('log_in'))


@app.route('/logout')
def logout():
    print(f"Logging out user from session{session}")
    session.pop("user", None)
    print(f"Session is now {session}")
    return redirect(url_for("home"))


def getUserId(username):
    if "user" in session:
        with sql.connect("database.db") as con:
            cur = con.cursor()
            userId = cur.execute("SELECT userid "
                                 "FROM users WHERE username = ?", (username,)).fetchone()[0]
            return userId
    else:
        return redirect(url_for("log_in"))


if __name__ == '__main__':
    # Create database if not already created
    try:
        databaseOps.intialDatabaseCreation()
    except:
        print("Database Already Created")

    app.run(debug=True, host='0.0.0.0', port=8080)