Skip to content

Instantly share code, notes, and snippets.

@otykhonruk
Created September 6, 2016 13:32
Show Gist options
  • Save otykhonruk/746a3587c8f9c235320032834d4406fd to your computer and use it in GitHub Desktop.
Save otykhonruk/746a3587c8f9c235320032834d4406fd to your computer and use it in GitHub Desktop.
import this
from random import choice
from django.conf import settings
from django.conf.urls import url
from django.core.management import execute_from_command_line
from django.http import HttpResponse
text = ''.join(this.d.get(c, c) for c in this.s)
title, _, *quotes = text.splitlines()
settings.configure(
DEBUG=True,
ROOT_URLCONF=__name__,
)
template = """
<!DOCTYPE html>
<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{quote}</h1>
</body>
</html>
"""
def quote(request):
return HttpResponse(template.format(title=title,
quote=choice(quotes)))
urlpatterns = [
url('^$', quote)
]
if __name__ == '__main__':
import sys
execute_from_command_line(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment