init commit
This commit is contained in:
3
werkout_api/__init__.py
Normal file
3
werkout_api/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from .celery import app as celery_app
|
||||
|
||||
__all__ = ['celery_app']
|
||||
16
werkout_api/asgi.py
Normal file
16
werkout_api/asgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for werkout_api project.
|
||||
|
||||
It exposes the ASGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'werkout_api.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
8
werkout_api/celery.py
Normal file
8
werkout_api/celery.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import os
|
||||
from celery import Celery
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'werkout_api.settings')
|
||||
|
||||
app = Celery('werkout_api')
|
||||
app.config_from_object('django.conf:settings', namespace='CELERY')
|
||||
app.autodiscover_tasks()
|
||||
213
werkout_api/settings.py
Normal file
213
werkout_api/settings.py
Normal file
@@ -0,0 +1,213 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
'debug_toolbar',
|
||||
'rest_framework',
|
||||
'rest_framework.authtoken',
|
||||
'import_export',
|
||||
'push_notifications',
|
||||
|
||||
'equipment',
|
||||
'exercise',
|
||||
'registered_user',
|
||||
'workout',
|
||||
'muscle',
|
||||
'scripts',
|
||||
'video',
|
||||
'superset',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'debug_toolbar.middleware.DebugToolbarMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'werkout_api.urls'
|
||||
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django_redis.cache.RedisCache",
|
||||
"LOCATION": "redis://redis:6379/",
|
||||
"OPTIONS": {
|
||||
"CLIENT_CLASS": "django_redis.client.DefaultClient"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
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',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'werkout_api.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/4.1/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
|
||||
|
||||
if os.environ.get("DATABASE_URL"):
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
# if os.environ.get("IS_DEV"):
|
||||
# DEBUG = True
|
||||
# PUSH_NOTIFICATIONS_SETTINGS = {
|
||||
# "APNS_CERTIFICATE": "certs/dev/prod_aps.pem",
|
||||
# "APNS_TOPIC": "io.brodkast.ios-Dev",
|
||||
# "APNS_TEAM_ID": "JCU65VV9D9",
|
||||
# "APNS_USE_SANDBOX": False
|
||||
# }
|
||||
# else:
|
||||
# DEBUG = False
|
||||
# PUSH_NOTIFICATIONS_SETTINGS = {
|
||||
# "APNS_CERTIFICATE": "certs/prod/prod_aps.pem",
|
||||
# "APNS_TOPIC": "io.brodkast.ios",
|
||||
# "APNS_TEAM_ID": "JCU65VV9D9",
|
||||
# "APNS_USE_SANDBOX": False
|
||||
# }
|
||||
|
||||
CSRF_TRUSTED_ORIGINS = ['https://*.werkout.fitness']
|
||||
SECRET_KEY = os.environ.get("SECRET_KEY", 'secret')
|
||||
|
||||
# Parse the DATABASE_URL env var.
|
||||
USER, PASSWORD, HOST, PORT, NAME = re.match("^postgres://(?P<username>.*?)\:(?P<password>.*?)\@(?P<host>.*?)\:(?P<port>\d+)\/(?P<db>.*?)$", os.environ.get("DATABASE_URL", "")).groups()
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': NAME,
|
||||
'USER': USER,
|
||||
'PASSWORD': PASSWORD,
|
||||
'HOST': HOST,
|
||||
'PORT': int(PORT),
|
||||
}
|
||||
}
|
||||
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django_redis.cache.RedisCache",
|
||||
"LOCATION": [os.environ.get('REDIS_URL', 'redis://localhost:6379')],
|
||||
"OPTIONS": {
|
||||
"CLIENT_CLASS": "django_redis.client.DefaultClient"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CELERY_BROKER_URL = os.environ.get("REDIS_URL", "") + "/1"
|
||||
CELERY_RESULT_BACKEND = os.environ.get("REDIS_URL", "") + "/1"
|
||||
|
||||
INTERNAL_IPS = [
|
||||
"127.0.0.1",
|
||||
]
|
||||
else:
|
||||
DEBUG = True
|
||||
ALLOWED_HOSTS = ['*']
|
||||
SECRET_KEY = 'django-insecure-o_0sbr3lxcy#_r#imo4tl0cw*%@*__2a48dcd6hbp&u9b5dx=1'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
CELERY_BROKER_URL = "redis://redis:6379"
|
||||
CELERY_RESULT_BACKEND = "redis://redis:6379"
|
||||
|
||||
INTERNAL_IPS = [
|
||||
"127.0.0.1",
|
||||
]
|
||||
|
||||
# PUSH_NOTIFICATIONS_SETTINGS = {
|
||||
# "APNS_CERTIFICATE": "certs/dev/dev_aps.pem",
|
||||
# "APNS_TOPIC": "io.brodkast.ios-Dev",
|
||||
# "APNS_TEAM_ID": "JCU65VV9D9",
|
||||
# "APNS_USE_SANDBOX": True
|
||||
# }
|
||||
39
werkout_api/urls.py
Normal file
39
werkout_api/urls.py
Normal file
@@ -0,0 +1,39 @@
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.shortcuts import HttpResponse
|
||||
|
||||
def ipa_plist(request):
|
||||
f = open('static/ipa/manifest.plist', 'r')
|
||||
file_content = f.read()
|
||||
f.close()
|
||||
return HttpResponse(file_content, content_type="application/x-plist")
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
|
||||
path('workout/', include('workout.urls')),
|
||||
path('exercise/', include('exercise.urls')),
|
||||
path('muscle/', include('muscle.urls')),
|
||||
path('equipment/', include('equipment.urls')),
|
||||
path('registered_user/', include('registered_user.urls')),
|
||||
path('.well-known/apple-app-site-association', TemplateView.as_view(template_name='frontend/apple-app-site-association', content_type='application/json',)),
|
||||
path('scripts/', include('scripts.urls')),
|
||||
path('videos/', include('video.urls')),
|
||||
|
||||
path('app/', TemplateView.as_view(template_name='frontend/download.html')),
|
||||
path('ipa_plist/', ipa_plist),
|
||||
] + static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
|
||||
|
||||
if settings.DEBUG:
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns += [
|
||||
path('__debug__/', include(debug_toolbar.urls)),
|
||||
]
|
||||
|
||||
# if settings.DEBUG:
|
||||
# urlpatterns.append(url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))
|
||||
16
werkout_api/wsgi.py
Normal file
16
werkout_api/wsgi.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for werkout_api project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'werkout_api.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
Reference in New Issue
Block a user