def index():
    form = ImportForm()
    if form.validate_on_submit():
        # Remove excessive whitespace from user input
        import_code = form.import_code.data.strip()
        return vendor(import_code)
    return render_template("index.html", form=form)
Exemple #2
0
def import_song():
    form = ImportForm()
    if form.validate_on_submit():
        song_json = json.loads(request.files[form.json.name].read())
        name = song_json.get('name')
        content = song_json.get('content')
        song = SongModel(name=name,content=content,added_by=users.get_current_user())
        try:
            song.put()
            song_id = song.key.id()
            flash(u'Song %s successfully saved.' % song_id, 'success')
            return redirect(url_for('list_songs'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('list_songs'))
        return redirect(url_for('list_songs'))