def upload_file(): print(request.form) event = EventModel() event.fk_userid = request.form.get('fk_userid') event.event_name = request.form.get('name') event.event_date = request.form.get('date') event.event_place = request.form.get('place') event.event_detail = request.form.get('detail') event.event_category = request.form.get('category') event.event_talent = request.form.get('talent') event.event_quota = request.form.get('quota') if 'file' not in request.files: flash('No File Part') return redirect(request.url) f = request.files['file'] if f.filename == '': flash('No selected file') if f: filename = secure_filename(f.filename) f.save(filename) event.event_image = filename event.save() return 'susccess'
def create_event(): event = EventModel() event.fk_userid = request.form.get('fk_userid') event.event_name = request.form.get('name') event.event_date = request.form.get('date') event.event_place = request.form.get('place') event.event_detail = request.form.get('detail') event.event_category = request.form.get('category') event.event_talent = request.form.get('talent') event.event_quota = request.form.get('quota') if 'file' not in request.files: flash('No File Part') return redirect(request.url) f = request.files['file'] if f.filename == '': flash('No selected file') if f: filename = secure_filename(f.filename) f.save(os.path.abspath("../image/" + filename)) event.event_image = request.host_url + 'image/' + filename event.save() ser_data = event_schema.dump(event).data return custom_response({'messages': 'success', 'event': ser_data}, 200)