diff --git a/Dockerfile b/Dockerfile index 4c464fdf..d250560a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - # # Read more on Dockerfile best practices at the source: # https://docs.docker.com/develop/develop-images/dockerfile_best-practices -RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client nodejs +RUN apt-get update && apt-get install -y --no-install-recommends postgresql-client nodejs npm # Inside the container, create an app directory and switch into it RUN mkdir /app diff --git a/manage.py b/manage.py index a54bfb13..a36cb464 100755 --- a/manage.py +++ b/manage.py @@ -5,7 +5,7 @@ def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'parserator_web.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "parserator_web.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -17,5 +17,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/parserator_web/apps.py b/parserator_web/apps.py index 02d93a45..bfdebb6e 100644 --- a/parserator_web/apps.py +++ b/parserator_web/apps.py @@ -2,4 +2,4 @@ class DjangoAppConfig(AppConfig): - name = 'parserator_web' + name = "parserator_web" diff --git a/parserator_web/asgi.py b/parserator_web/asgi.py index 099ca854..967bd250 100644 --- a/parserator_web/asgi.py +++ b/parserator_web/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'parserator_web.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "parserator_web.settings") application = get_asgi_application() diff --git a/parserator_web/management/commands/clear_cache.py b/parserator_web/management/commands/clear_cache.py index 94e6c815..86fa6f8b 100644 --- a/parserator_web/management/commands/clear_cache.py +++ b/parserator_web/management/commands/clear_cache.py @@ -6,15 +6,14 @@ class Command(BaseCommand): """A simple management command which clears the site-wide cache.""" - help = 'Fully clear your site-wide cache.' + + help = "Fully clear your site-wide cache." def handle(self, *args, **kwargs): try: assert settings.CACHES except AttributeError: - raise CommandError( - 'No cache configured. Check CACHES in settings.py.' - ) + raise CommandError("No cache configured. Check CACHES in settings.py.") cache.clear() - self.stdout.write('Successfully cleared the cache.') + self.stdout.write("Successfully cleared the cache.") diff --git a/parserator_web/settings.py b/parserator_web/settings.py index e4614696..5e473a1c 100644 --- a/parserator_web/settings.py +++ b/parserator_web/settings.py @@ -9,6 +9,7 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.0/ref/settings/ """ + import os import dj_database_url @@ -17,78 +18,78 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Retrieve the secret key from the DJANGO_SECRET_KEY environment variable -SECRET_KEY = os.environ['DJANGO_SECRET_KEY'] +SECRET_KEY = os.environ["DJANGO_SECRET_KEY"] # Set the DJANGO_DEBUG environment variable to False to disable debug mode -DEBUG = False if os.getenv('DJANGO_DEBUG', True) == 'False' else True +DEBUG = False if os.getenv("DJANGO_DEBUG", True) == "False" else True # Define DJANGO_ALLOWED_HOSTS as a comma-separated list of valid hosts, # e.g. localhost,127.0.0.1,.herokuapp.com -allowed_hosts = os.getenv('DJANGO_ALLOWED_HOSTS', []) -ALLOWED_HOSTS = allowed_hosts.split(',') if allowed_hosts else [] +allowed_hosts = os.getenv("DJANGO_ALLOWED_HOSTS", []) +ALLOWED_HOSTS = allowed_hosts.split(",") if allowed_hosts else [] # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'parserator_web' + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "parserator_web", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'whitenoise.middleware.WhiteNoiseMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "whitenoise.middleware.WhiteNoiseMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'parserator_web.urls' +ROOT_URLCONF = "parserator_web.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ['templates/'], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": ["templates/"], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, ] -WSGI_APPLICATION = 'parserator_web.wsgi.application' +WSGI_APPLICATION = "parserator_web.wsgi.application" # Database # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = {} -DATABASES['default'] = dj_database_url.parse( - os.getenv('DATABASE_URL', 'postgres://postgres:postgres@postgres:5432/parserator'), +DATABASES["default"] = dj_database_url.parse( + os.getenv("DATABASE_URL", "postgres://postgres:postgres@postgres:5432/parserator"), conn_max_age=600, - ssl_require=True if os.getenv('POSTGRES_REQUIRE_SSL') else False + ssl_require=True if os.getenv("POSTGRES_REQUIRE_SSL") else False, ) # Caching # https://docs.djangoproject.com/en/3.0/topics/cache/ -cache_backend = 'dummy.DummyCache' if DEBUG is True else 'db.DatabaseCache' +cache_backend = "dummy.DummyCache" if DEBUG is True else "db.DatabaseCache" CACHES = { - 'default': { - 'BACKEND': f'django.core.cache.backends.{cache_backend}', - 'LOCATION': 'site_cache', + "default": { + "BACKEND": f"django.core.cache.backends.{cache_backend}", + "LOCATION": "site_cache", } } @@ -97,25 +98,25 @@ AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -126,18 +127,18 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/2.2/howto/static-files/ -STATIC_URL = '/static/' -STATIC_ROOT = '/static' +STATIC_URL = "/static/" +STATIC_ROOT = "/static" STATICFILES_STORAGE = os.getenv( - 'DJANGO_STATICFILES_STORAGE', - 'whitenoise.storage.CompressedManifestStaticFilesStorage' + "DJANGO_STATICFILES_STORAGE", + "whitenoise.storage.CompressedManifestStaticFilesStorage", ) STATICFILES_FINDERS = ( - 'django.contrib.staticfiles.finders.FileSystemFinder', - 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + "django.contrib.staticfiles.finders.FileSystemFinder", + "django.contrib.staticfiles.finders.AppDirectoriesFinder", ) # Enforce SSL in production if DEBUG is False: - SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") SECURE_SSL_REDIRECT = True diff --git a/parserator_web/templates/parserator_web/index.html b/parserator_web/templates/parserator_web/index.html index a72d9c80..56156e42 100644 --- a/parserator_web/templates/parserator_web/index.html +++ b/parserator_web/templates/parserator_web/index.html @@ -11,7 +11,7 @@
Dealing with some messy or unstructured addresses? We can parse them for you.
Try it out! Parse an address in the United States into fields like AddressNumber
, StreetName
and ZipCode
.