Ejemplo n.º 1
0
def get_event(event):
    log.write(request.method+' on /event/'+event + " ip: " + getip(request)+"\n")
    log.flush()
    if request.method == 'GET':
        eventlink = event
        eventname = event.split('_')[0]
        
        '''get the images from the database'''
        imagelist = database.get_event_pics(eventlink,g)
        log.write('Images for event:'+eventlink+' are:\n'+str(imagelist)+"\n")
        log.flush()
        
        status = database.get_event_status(eventlink,g)
        
        '''generate the html page with the images found'''
        response = make_response(render_template('event.html',
                    url='http://128.237.228.158:5000/event/' + eventlink,
                    eventname = eventname, eventlink = eventlink,
                    imagelist = imagelist,status=status))
                                
        '''Putting a cookie if one was not found'''
        if('user' not in request.cookies):
            log.write("No cookie found in user adding cookie for " + getip(request)+"\n")
            log.flush()
            response.set_cookie('user', getip(request))
            ret = database.add_user_inevent(event,getip(request),g)
        return response    
Ejemplo n.º 2
0
def poll(event):
    log.write("POST on /poll/"+event+"\n")
    log.flush()
    
    room.wait()
    statuslist = []
    status = database.get_event_status(event,g)    
    statuslist.append(status)
    imagelist = []
    
    imagelist = database.get_event_pics(event,g)
        
    statuslist.append(imagelist)
    log.write("The database returned :" + str(statuslist)+ "\n");    
    log.write("Wait over for user:"******" /poll/"+event+" status is:"+status+"\n")
    log.flush()
    
    return jsonify(status=statuslist)