Created
September 6, 2016 13:32
-
-
Save otykhonruk/746a3587c8f9c235320032834d4406fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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