Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# build_files.sh

pip install -r requirements.txt
python3.9 manage.py collectstatic --noinput
17 changes: 10 additions & 7 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import os
import django_heroku
from django.conf import settings
from dotenv import load_dotenv

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

# load environment variables
load_dotenv()

# Quick-start development settings - unsuitable for production

Expand All @@ -16,7 +19,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS = ['*']
ALLOWED_HOSTS = ["127.0.0.1", ".vercel.app", ".now.sh"]

# Application definition

Expand Down Expand Up @@ -131,12 +134,12 @@

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django-server',
'USER': 'dbuser',
'PASSWORD': 'Rabbani@123',
'HOST': 'django-server.mysql.database.azure.com',
'PORT': '3306',
'ENGINE': os.getenv("DB_ENGINE"),
'NAME': os.getenv("DB_NAME"),
'USER': os.getenv("DB_USER"),
'PASSWORD': os.getenv("DB_PASSWORD"),
'HOST': os.getenv("DB_HOST"),
'PORT': os.getenv("DB_PORT"),
}
}

Expand Down
3 changes: 3 additions & 0 deletions main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
2 changes: 2 additions & 0 deletions main/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')

application = get_wsgi_application()

app = application
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ py
pycodestyle
pyparsing
pytest
python-dotenv
python-slugify
pytz
redis
Expand Down
29 changes: 29 additions & 0 deletions versel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# versel.json
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the file name be versel.json or vercel.json? Also technically a comment in JSON does not work.


{
"version": 2,
"builds": [
{
"src": "main/wsgi.py",
"use": "@vercel/python",
"config": { "maxLambdaSize": "15mb", "runtime": "python3.9" }
},
{
"src": "build_files.sh",
"use": "@vercel/static-build",
"config": {
"distDir": "staticfiles"
}
}
],
"routes": [
{
"src": "/static/(.*)",
"dest": "/static/$1"
},
{
"src": "/(.*)",
"dest": "main/wsgi.py"
}
]
}