Demo entry 3548941



Submitted by anonymous on Jan 20, 2016 at 11:40
Language: Python. Code size: 744 Bytes.

from django.shortcuts import render, redirect, get_object_or_404
from django.views.generic import TemplateView, View
# Create your views here.
from markdown import markdown

from paste.models import Code

class NewPasteView(TemplateView):
    template_name = 'new.html'

    def post(self, request, *args, **kwargs):
        org_text = request._post['code']
        md_text = markdown(org_text)
        code = Code(org_text=org_text, md_text=md_text)
        return redirect('/show/%s/' %

class ShowView(TemplateView):
    template_name = 'show.html'

    def get_context_data(self, **kwargs):
        code = get_object_or_404(Code, id=kwargs.get('id', 0))
        return {'code': code}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).