diff --git a/.gitignore b/.gitignore index 748a6af..a08cf7d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ dist/ *.sqlite3 *.db static_root/ -test.html \ No newline at end of file +test.html +local.py \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..6a5cfe4 --- /dev/null +++ b/install.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +pip install --upgrade pip +pip install -r requirements.txt +python manage.py migrate +echo "yes" | python manage.py collectstatic +python manage.py createsuperuser \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..638ae88 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +Django==1.11.18 +djangorestframework==3.9.1 +pytz==2018.9 +tokenauth==0.9.1 +django-cors-headers==2.4.0 +RPi.GPIO==0.6.5 \ No newline at end of file diff --git a/restpi/settings/local.py b/restpi/settings/local.py.sample similarity index 100% rename from restpi/settings/local.py rename to restpi/settings/local.py.sample diff --git a/restpi/settings/prod.py b/restpi/settings/prod.py index ff8254c..72641dd 100644 --- a/restpi/settings/prod.py +++ b/restpi/settings/prod.py @@ -1,4 +1,13 @@ +import re +import subprocess + +ip_patt = re.compile("inet\saddr\:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})") +process = subprocess.Popen(["ifconfig"], stdout=subprocess.PIPE) +output = process.stdout.read() + +ip_list = ip_patt.findall(output) + # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -ALLOWED_HOSTS = ['localhost'] \ No newline at end of file +ALLOWED_HOSTS = ip_list \ No newline at end of file diff --git a/restpi/urls.py b/restpi/urls.py index 03ec26a..1664ab0 100644 --- a/restpi/urls.py +++ b/restpi/urls.py @@ -15,6 +15,8 @@ Including another URLconf """ from django.conf.urls import url, include from django.contrib import admin +from django.conf import settings +from django.views.static import serve from restpi.views import Index, Login, Logout @@ -27,3 +29,8 @@ urlpatterns = [ url(r'^pins/', include('pins.urls')), url(r'', include('tokenauth.urls')), ] + +if not settings.DEBUG: + urlpatterns += [ + url(r'^static/(?P.*)$', serve, {'document_root': settings.STATIC_ROOT}), + ]