Skip to content

Latest commit

 

History

History
43 lines (35 loc) · 758 Bytes

hello-world-minimalista.md

File metadata and controls

43 lines (35 loc) · 758 Bytes

Hello World Minimalista

Eis a menor aplicação Django possível...

#
# Settings
#
from django.conf import settings

settings.configure(
    DEBUG = True,
    ALLOWED_HOSTS = ['localhost'],
    ROOT_URLCONF = '__main__',
    MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.middleware.clickjacking.XFrameOptionsMiddleware',
    ),
)

#
# View
#
from django.conf.urls import url
from django.http import HttpResponse

def index(request):
    return HttpResponse('Hello World')

urlpatterns = (
    url(r'^$', index),
)


#
# Terminal
#
import sys
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)