Skip to content

Commit 49c8fe1

Browse files
committed
setup backend django server
1 parent 7d5e7ab commit 49c8fe1

19 files changed

+437
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,5 @@ sketch
182182
# End of https://www.toptal.com/developers/gitignore/api/react
183183

184184
tags
185+
.env
186+
.vim/

backend/Backend/__init__.py

Whitespace-only changes.

backend/Backend/asgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for Backend 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', 'Backend.settings')
15+
16+
application = get_asgi_application()

backend/Backend/settings.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
from pathlib import Path
2+
import os
3+
4+
BASE_DIR = Path(__file__).resolve().parent.parent
5+
6+
SECRET_KEY = os.environ.get('secret_key')
7+
8+
DEBUG = True
9+
10+
ALLOWED_HOSTS = []
11+
12+
INSTALLED_APPS = [
13+
'django.contrib.admin',
14+
'django.contrib.auth',
15+
'django.contrib.contenttypes',
16+
'django.contrib.sessions',
17+
'django.contrib.messages',
18+
'django.contrib.staticfiles',
19+
20+
'core.apps.CoreConfig'
21+
]
22+
23+
MIDDLEWARE = [
24+
'django.middleware.security.SecurityMiddleware',
25+
'django.contrib.sessions.middleware.SessionMiddleware',
26+
'django.middleware.common.CommonMiddleware',
27+
'django.middleware.csrf.CsrfViewMiddleware',
28+
'django.contrib.auth.middleware.AuthenticationMiddleware',
29+
'django.contrib.messages.middleware.MessageMiddleware',
30+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
31+
]
32+
33+
ROOT_URLCONF = 'Backend.urls'
34+
35+
TEMPLATES = [
36+
{
37+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
38+
'DIRS': [],
39+
'APP_DIRS': True,
40+
'OPTIONS': {
41+
'context_processors': [
42+
'django.template.context_processors.debug',
43+
'django.template.context_processors.request',
44+
'django.contrib.auth.context_processors.auth',
45+
'django.contrib.messages.context_processors.messages',
46+
],
47+
},
48+
},
49+
]
50+
51+
WSGI_APPLICATION = 'Backend.wsgi.application'
52+
53+
DATABASES = {
54+
'default': {
55+
'ENGINE': 'django.db.backends.sqlite3',
56+
'NAME': BASE_DIR / 'db.sqlite3',
57+
}
58+
}
59+
60+
61+
AUTH_PASSWORD_VALIDATORS = [
62+
{
63+
'NAME':
64+
'django.contrib.auth.password_validation.' +
65+
'UserAttributeSimilarityValidator',
66+
},
67+
{
68+
'NAME':
69+
'django.contrib.auth.password_validation.MinimumLengthValidator',
70+
},
71+
{
72+
'NAME':
73+
'django.contrib.auth.password_validation.CommonPasswordValidator',
74+
},
75+
{
76+
'NAME':
77+
'django.contrib.auth.password_validation.NumericPasswordValidator',
78+
},
79+
]
80+
81+
82+
LANGUAGE_CODE = 'en-us'
83+
84+
TIME_ZONE = 'UTC'
85+
86+
USE_I18N = True
87+
88+
USE_L10N = True
89+
90+
USE_TZ = True
91+
92+
STATIC_URL = '/static/'

backend/Backend/urls.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.contrib import admin
2+
from django.urls import path
3+
4+
urlpatterns = [
5+
path('admin/', admin.site.urls),
6+
]

backend/Backend/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for Backend 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', 'Backend.settings')
15+
16+
application = get_wsgi_application()

backend/Pipfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[[source]]
2+
url = "https://pypi.python.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
django = "*"
8+
djangorestframework = "*"
9+
10+
[dev-packages]
11+
django-linter = "*"
12+
pylint = "*"
13+
isort = "*"
14+
15+
[requires]
16+
python_version = "3.8"

backend/Pipfile.lock

Lines changed: 137 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/core/__init__.py

Whitespace-only changes.

backend/core/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

backend/core/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CoreConfig(AppConfig):
5+
name = 'core'

backend/core/migrations/__init__.py

Whitespace-only changes.

backend/core/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

backend/core/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

backend/core/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.urls import path
2+
3+
APP_NAME = 'core'
4+
5+
urlpatterns = [
6+
path(),
7+
]

backend/core/views.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

backend/manage.py

Lines changed: 22 additions & 0 deletions
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', 'Backend.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()

0 commit comments

Comments
 (0)