def flight_add(): if request.method == 'POST': event_name = request.form['event_name'] venue = request.form['venue'] event_date = int(request.form['event_date']) Event(event_name, event_date, venue).save_to_mongo() return redirect(url_for(".index")) return render_template('flights/new_flight.html')
def initialize(self, db): self.db = db self.event = Event(self.db) self.params = {} for param in self.request.arguments: self.params[param] = self.request.arguments[param][0] return self.params
def index(): events = Event.all() #Listening for message try: response = TripConstants.sqs.receive_message( QueueUrl=TripConstants.queue_url, #queue url for identiying queue AttributeNames=[ #Metadata 'SentTimestamp' ], MaxNumberOfMessages=1, MessageAttributeNames=['All'], VisibilityTimeout=0, WaitTimeSeconds=0) if 'Messages' in response: #Checking for Messages for msg in response['Messages']: # print('Got msg "{0}"'.format(msg['Body'])) print('got queue message') else: print('No messages in queue') print("Try First") print(response['Messages'][0]) message = response['Messages'][ 0] # Storing 1st message from response in message print("Try Second") Attr = message['MessageAttributes'] # Retrieving metadata from message print('before Handle') receipt_handle = message[ 'ReceiptHandle'] #Receit Handle is generated on receipt of program and is needed for deleting print('before Delete') # Delete received message from queue will raise error if try to delete from empty queue TripConstants.sqs.delete_message( #Deleting Messages QueueUrl=TripConstants.queue_url, ReceiptHandle=receipt_handle) #print('Received and deleted message: %s' % message['Body']) print(Attr['Sender']['StringValue']) global city city = message['MessageAttributes']['Sender']['StringValue'] if city is None: # Mesevent.city = city print("no city value received") # Mesevent.save_to_mongo() # time.sleep(1) print('MetaData: %s' % message['MessageAttributes']) print('Received and deleted message: %s' % message['Body']) #Printing Message time.sleep(5) print("before saving to db") except: print("Sorry no messages for you") #No message Found return render_template('flights/flight_index.html', events=events)
def flight_book(event_name, event_date, venue): if request.method == 'POST': event_name = event_name event_date = event_date venue = venue order = { "event_name": event_name, "event_date": event_date, "venue": venue } user = User.find_by_email(session['email']) user.orders = {uuid.uuid4().hex: order} print(user) Event(event_name, event_date, venue).save_to_mongo() events = Event.all() return render_template('flights/flight_index.html', events=events)
def jsonOutput(): events = Event.all() print(events) output = [] for e in events: output.append({ 'event_name': e.event_name, 'event_date': e.event_date, 'venue': e.venue }) print(output) return jsonify({'events': output})
def delete_flight(_id): Event.get_by_id(_id).delete() return redirect(url_for('.index'))
def flight_page(_id): event = Event.get_by_id(_id) return render_template("events/flight.html", event=event)