Ejemplo n.º 1
0
def load_user(id):

    # check if user exists in database (security)
    # If yes, returns the user
    # Else, empty
    lower_id = id.lower()
    db_controller = Controller()
    data = db_controller.not_exist_username(lower_id)

    if not data:
        user = users(lower_id, 0)
    else:
        user = users("", 0)
    return user
Ejemplo n.º 2
0
def usuarios():
    if request.method == 'GET':
        users = user.users()
        return render_template('user.html', users=users)
    if request.method == 'POST':
        reposta = json.loads(request.form['data'])
        user.user_novo_update(reposta)
    return 'Usuario atualizado'
Ejemplo n.º 3
0
from user import users

users=[users(1,'Shafin','hamna'),
       users(1, 'Hamna', 'haiqa'),
       users(1, 'Haiqa', 'ShafinHamna'),]

username_mapping={u.username:u for u in users}
userid_mapping ={u.id:u for u in users}

def authenticate(username,password):
    user= username_mapping.get(username,None)
    if user and user.password==password:
        return user

def identity(payload):
    usr_id=payload['identity']
    return userid_mapping.get(usr_id,None)
Ejemplo n.º 4
0
from calculator import calculator
from user import users

user1 = users()
#user2=users()
ans = user1.start()
#user2.start()
user1.join()
print(ans)

#data="2+35/5"
#data=input()
#obj1=calculator()
#expr, ans= obj1.get()
#obj1.infix()
#print (expr, ans)
Ejemplo n.º 5
0
    print '%-10s %s' % (' log', ':日志管理')
    exit(2)

if len(sys.argv) == 2:
    if cmd == 'user':
        print '%-35s %s' % (' add <username>', ':添加用户')
        print '%-35s %s' % (' del <username>', ':删除用户')
        print '%-35s %s' % (' alter <username> <key> <value>', ':修改用户属性')
        print '%-35s %s' % (' list', ':列出所有用户')
        print '%-35s %s' % (' show <usrname>', ':显示用户详细信息')
        exit(3)
    if cmd == 'route':
        print '%-30s %s' % (' create <route> [commet]', ':创建路由')
        print '%-30s %s' % (' del <route-id>', ':删除路由')
        print '%-30s %s' % (' add <route-id> <username>', ':添加用户路由')
    print '%-30s %s' % (' show <username>', ':显示用户路由')
    print '%-30s %s' % (' list', ':列出所有路由')
    exit(3)

cmdopt = sys.argv
if cmd == 'user':
    user.users(cmdopt)
    #cmd = args[3]
    #print cmd

if cmd == 'route':
    route.routes(cmdopt)

if cmd == 'log':
    log.logs(cmdopt)
Ejemplo n.º 6
0
from flask import Flask
from flask_login import LoginManager

app = Flask(__name__)
app.config["SECRET_KEY"] = "Highly secret key"
numList = []

login_manager = LoginManager()
login_manager.init_app(app)

#
from user import users
#
currentUser = users("", 0)