Example #1
0
def create():
    
    if request.method == 'POST' and 'json' in request.form:
        
        try:
            # turn the pasted json into python
            the_json = request.form.get('json')
            the_json = simplejson.loads(the_json)
            
            # handle a temporary paste if necessary
            temporary = False
            if 'temporary' in request.form:
                temporary = bool(request.form.get('temporary'))
            
            # save it
            paste_id = queries.paste_create(the_json, temporary)
            
            # redirect to it
            if paste_id:
                return redirect(url_for('paste.view', id=paste_id))
            
        except:
            flash('That was not valid JSON. For a JSON reference, please refer to <a href="http://json.org/" target="_blank">json.org</a>.')
            return redirect(url_for('fluff.create'))
        
    return render_template('fluff/create.html')
Example #2
0
def create():

    if request.method == 'POST' and 'json' in request.form:

        try:
            # turn the pasted json into python
            the_json = request.form.get('json')
            the_json = simplejson.loads(the_json)

            # handle a temporary paste if necessary
            temporary = False
            if 'temporary' in request.form:
                temporary = bool(request.form.get('temporary'))

            # save it
            paste_id = queries.paste_create(the_json, temporary)

            # redirect to it
            if paste_id:
                return redirect(url_for('paste.view', id=paste_id))

        except:
            flash(
                'That was not valid JSON. For a JSON reference, please refer to <a href="http://json.org/" target="_blank">json.org</a>.'
            )
            return redirect(url_for('fluff.create'))

    return render_template('fluff/create.html')
Example #3
0
def create():
    if request.method == 'POST' and request.form.get('json'):

        try:
            # turn the pasted json into python
            the_json = request.form.get('json')
            the_json = simplejson.loads(the_json)

            # save it
            paste_id = queries.paste_create(the_json)

            # return the paste id
            if paste_id:
                return jsonify({'id': str(paste_id)})

        except:
            raise abort(501)

    # nothing to paste
    raise abort(403)