def delsession(username): sessionobj = Sessions(username) session_id = sessionobj.readsessionid(username) sessionobj.delsession(session_id) resp = make_response(jsonify(status='success'), 200) # socket. return resp
def post(self, *args, **kwargs): try: login = self.get_argument_smart('username', as_get=False, as_post=True, as_session=False, as_cookie=False) passwd = self.get_argument_smart('passwd', as_get=False, as_post=True, as_session=False, as_cookie=False) except Exception as err: abort(403) try: passwd = sha.new(passwd).hexdigest() except: abort(403) user = session.query(Users).filter(Users.login == login).filter( Users.passwd == passwd).first() if user is None: abort(403) flask_session['session'] = Sessions().create(user.id) return Response(self.get_as_json())
def on_join(data): sessionobj = Sessions(data['username']) username = data['username'] room = sessionobj.readsessionid(data['room']) # room = data['room'] # join_room(room) # send(username + ' has entered the room.', room=room) emit('sentdirect', data, room=room, include_self=False)
def __init__(self, url, access_id, access_key): self.timer = Timer(Config.request_interval, self.task) self.sessions = Sessions() self.performance = Performance() self.url = url + Config.endpoint self.auth = (access_id, access_key) self.timestamp = int(time.time()) self.start()
def loginmsg(loggedin): print('This is {}'.format(loggedin)) sessionobj = Sessions(loggedin['user']) sessionadded = sessionobj.addsession(request.sid) print(sessionadded) if sessionadded == 'error': # resp=make_response(jsonify(status='success'),200) resp = 'exist' else: # resp=make_response(jsonify(status='success'),200) emit('sessionadd', loggedin['user'], include_self=False, broadcast=True) resp = 'success' return resp
def dispatch(self, *args, **kwargs): Sessions().delete(self.request.user.id) return Response(redirect(url_for('admin:login')))
from sessions import Sessions import pprint pp = pprint.PrettyPrinter(indent=4) s = Sessions() pp.pprint(s.get_session(148).get_session_mps())
def addsessions(username): sessionobj = Sessions(username) sessionadded = sessionobj.addsession() resp = make_response(jsonify(status='success'), 200) return resp
def getsession(username): sessionobj = Sessions(username) onlinesessions = sessionobj.readsession() resp = make_response(jsonify(sessions=onlinesessions), 200) return resp
settings = dict( MOTOR_URI='mongodb://*****:*****@app.middleware('request') async def add_session(request): request['session'] = session app.config.AUTH_LOGIN_URL = '/Signin' auth = Sessions(app) from beacons.controllers.login import login_page from beacons.controllers.map import map_page from beacons.controllers.beacon import beacon_page from beacons.controllers.photo_controller import photo_page app.blueprint(login_page) app.blueprint(map_page) app.blueprint(beacon_page) app.blueprint(photo_page)
def __init__(self, url): self.timer = Timer(Config.request_interval, self.task) self.sessions = Sessions() self.url = url self.timestamp = int(time.time()) self.start()