def create(): location = request.form.get('location') date = request.form.get('date') time = request.form.get('time') event_name = request.form.get('event_name') description = request.form.get('description') establishment_id = request.form.get('establishment_id') events = Event(location=location, date=date, time=time, event_name=event_name, description=description, establishment_id=establishment_id) try: events.save() flash('Event registered successfully', 'success') return redirect(url_for('events.index')) except: flash('Error creating event', 'danger') return redirect(url_for('events.new'))
def post(self): payload = request.get_data() json_data = json.loads(payload) event = Event( json_data.get("id"), json_data.get("userid"), json_data.get("noun"), datetime.datetime.now(), json_data.get("latlong"), json_data.get("verb"), json_data.get("timespent"), json_data.get("properties") ) xx = event.save() RulesEngine().execute(json_data) xx = json.dumps(event, cls=AlchemyEncoder) return {"response": json.loads(xx), "status": "success"}