예제 #1
0
def index():
    if request.method == 'POST':
        id = request.form['id']
        name = request.form['name']
        created = request.form['created']
        status = request.form['status']
        photo_url = request.form['photo_url']
        event_url = request.form['event_url']
        description = request.form['description']

        event = Event(id=id,
                      name=name,
                      created=created,
                      status=status,
                      photo_url=photo_url,
                      event_url=event_url,
                      description=description)

        db.session.add(event)

        db.session.commit()

    events = Event.query.all()

    response_object = {
        'status': 'success',
        'data': {
            'events': [event.to_json() for event in events]
        }
    }
    return jsonify(response_object), 200
예제 #2
0
def index():
    if request.method == "POST":
        id = request.form["id"]
        name = request.form["name"]
        created = request.form["created"]
        status = request.form["status"]
        photo_url = request.form["photo_url"]
        event_url = request.form["event_url"]
        description = request.form["description"]
        group_name = request.form["group_name"]
        member_type = request.form["member_type"]
        time = request.form["time"]
        source = request.form["source"]

        event = Event(
            id=id,
            name=name,
            created=created,
            status=status,
            photo_url=photo_url,
            event_url=event_url,
            description=description,
            group_name=group_name,
            member_type=member_type,
            time=time,
            source=source,
        )

        db.session.add(event)

        db.session.commit()

    events = Event.query.all()

    response_object = {
        "status": "success",
        "data": {"events": [event.to_json() for event in events]},
    }
    return jsonify(response_object), 200