Last active
March 24, 2017 14:09
-
-
Save nenodias/14e91b1ce657b53dcf1bd5658e05d80c to your computer and use it in GitHub Desktop.
Django Example
This file contains hidden or 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
| # *-* coding: utf-8 *-* | |
| '''Arquivo settings.py''' | |
| import sys | |
| import os | |
| from django.conf import settings | |
| DEBUG = os.environ.get('DEBUG', 'on') == 'on' | |
| SECRET_KEY = os.environ.get('SECRET_KEY', '{{ secret_key}}') | |
| ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', 'localhost').split(',') | |
| settings.configure( | |
| DEBUG=DEBUG, | |
| SECRET_KEY=SECRET_KEY, | |
| ALLOWED_HOSTS=ALLOWED_HOSTS, | |
| ROOT_URLCONF=__name__, | |
| MIDDLEWARE_CLASSES=( | |
| 'django.middleware.common.CommonMiddleware', | |
| 'django.middleware.csrf.CsrfViewMiddleware', | |
| 'django.middleware.clickjacking.XFrameOptionsMiddleware', | |
| ), | |
| ) | |
| '''Arquivo views.py''' | |
| from django.http import HttpResponse | |
| def index(request): | |
| return HttpResponse("Olá mundo") | |
| '''Arquivo urls.py''' | |
| from django.conf.urls import url | |
| urlpatterns = (url(r'^$', index), ) | |
| from django.core.wsgi import get_wsgi_application | |
| application = get_wsgi_application() | |
| '''Arquivo manage.py''' | |
| if __name__ == "__main__": | |
| from django.core.management import execute_from_command_line | |
| if len(sys.argv) > 0: | |
| execute_from_command_line(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment