Exemplo n.º 1
0
def new_url(request):
    if request.method == 'POST':
        form = NewLinkForm(request.POST)
        if form.is_valid():
            link = form.save()
            url = "http://localhost:9000/link/%s" % link.key
            return HttpResponseRedirect(url)
    else:
        form = NewLinkForm()

    return locals()
Exemplo n.º 2
0
def home(request):
    if request.method == 'POST':
        form = NewLinkForm(request.POST)
        if form.is_valid():
            form.save()

    form = NewLinkForm()

    links = Link.objects.all()

    data = {'links': links, 'form': form}

    return render(request, 'home.html', data)
Exemplo n.º 3
0
def index():
    form = NewLinkForm()
    if form.validate_on_submit():
        session['source_url'] = form.source_url.data
        return redirect(url_for('new_poster'))
    session.pop('source_url', None)
    return render_template('index.html', form=form, upload_form=UploadForm())
Exemplo n.º 4
0
def upload():
    form = UploadForm()
    if form.validate_on_submit():
        upload_result = cloudinary_upload(form.file.data)
        session['source_url'] = upload_result['secure_url']
        flash('Your poster has been successfully uploaded!')
        return redirect(url_for('new_poster'))
    return render_template('index.html', form=NewLinkForm(), upload_form=form)