Skip to content

Commit fd41211

Browse files
committed
'init'
0 parents  commit fd41211

36 files changed

+483
-0
lines changed

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.9
2+
3+
ENV PYTHONDONTWRITEBITECODE 1
4+
ENV PYTHONUNBUFFERED 1
5+
6+
WORKDIR /code
7+
8+
COPY . /code
9+
10+
RUN pip install pipenv
11+
12+
RUN pipenv install --system --deploy

Pipfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
django = "*"
8+
djangorestframework = "*"
9+
psycopg2-binary = "*"
10+
11+
[dev-packages]
12+
13+
[requires]
14+
python_version = "3.9"

Pipfile.lock

+101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__pycache__/check.cpython-39.pyc

576 Bytes
Binary file not shown.

blogapi/__init__.py

Whitespace-only changes.
116 Bytes
Binary file not shown.
2.31 KB
Binary file not shown.
893 Bytes
Binary file not shown.
519 Bytes
Binary file not shown.

blogapi/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for blogapi project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blogapi.settings')
15+
16+
application = get_asgi_application()

blogapi/settings.py

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
"""
2+
Django settings for blogapi project.
3+
4+
Generated by 'django-admin startproject' using Django 3.1.7.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.1/ref/settings/
11+
"""
12+
import os
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = os.environ.get('SECRET_KEY')
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = os.environ.get('DEBUG')
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
41+
# third-party
42+
'rest_framework',
43+
44+
# local
45+
'posts.apps.PostsConfig',
46+
47+
]
48+
49+
MIDDLEWARE = [
50+
'django.middleware.security.SecurityMiddleware',
51+
'django.contrib.sessions.middleware.SessionMiddleware',
52+
'django.middleware.common.CommonMiddleware',
53+
'django.middleware.csrf.CsrfViewMiddleware',
54+
'django.contrib.auth.middleware.AuthenticationMiddleware',
55+
'django.contrib.messages.middleware.MessageMiddleware',
56+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
57+
]
58+
59+
ROOT_URLCONF = 'blogapi.urls'
60+
61+
TEMPLATES = [
62+
{
63+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
64+
'DIRS': [os.path.join(BASE_DIR, 'templates')],
65+
'APP_DIRS': True,
66+
'OPTIONS': {
67+
'context_processors': [
68+
'django.template.context_processors.debug',
69+
'django.template.context_processors.request',
70+
'django.contrib.auth.context_processors.auth',
71+
'django.contrib.messages.context_processors.messages',
72+
],
73+
},
74+
},
75+
]
76+
77+
WSGI_APPLICATION = 'blogapi.wsgi.application'
78+
79+
80+
# Database
81+
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases
82+
83+
DATABASES = {
84+
'default': {
85+
'ENGINE': 'django.db.backends.postgresql',
86+
'NAME': 'django',
87+
'USER':os.environ.get('POSTGRES_USER'),
88+
'PASSWORD':os.environ.get('POSTGRES_PASSWORD'),
89+
'HOST':'db',
90+
'PORTS':5432
91+
}
92+
}
93+
94+
95+
# Password validation
96+
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
97+
98+
AUTH_PASSWORD_VALIDATORS = [
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
101+
},
102+
{
103+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
104+
},
105+
{
106+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
107+
},
108+
{
109+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
110+
},
111+
]
112+
113+
114+
# Internationalization
115+
# https://docs.djangoproject.com/en/3.1/topics/i18n/
116+
117+
LANGUAGE_CODE = 'en-us'
118+
119+
TIME_ZONE = 'UTC'
120+
121+
USE_I18N = True
122+
123+
USE_L10N = True
124+
125+
USE_TZ = True
126+
127+
128+
# Static files (CSS, JavaScript, Images)
129+
# https://docs.djangoproject.com/en/3.1/howto/static-files/
130+
131+
STATIC_URL = '/static/'

blogapi/urls.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""blogapi URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.1/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
]

blogapi/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for blogapi project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blogapi.settings')
15+
16+
application = get_wsgi_application()

check.py

Whitespace-only changes.

docker-compose.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
web:
3+
build: .
4+
command: python manage.py runserver 0.0.0.0:8000
5+
6+
environment:
7+
- "DEBUG=0"
8+
- "SECRET_KEY=*2t$t!p-pa38rnvk7^dec+ki%66vpxtyw#0tzk6xy(n6$b%3@a"
9+
- "POSTGRES_USER=postgres"
10+
- "POSTGRES_PASSWORD=postgres"
11+
12+
volumes:
13+
- ".:/code"
14+
15+
ports:
16+
- "8000:8000"
17+
18+
depends_on:
19+
- db
20+
db:
21+
image: postgres:13
22+
23+
environment:
24+
- "POSTGRES_USER=postgres"
25+
- "POSTGRES_PASSWORD=postgres"
26+
volumes:
27+
- postgres_data:/var/lib/postgresql/data
28+
29+
volumes:
30+
postgres_data:

manage.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blogapi.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

modules/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .modeltestcase import ModelTestCase
167 Bytes
Binary file not shown.
881 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)