added installation and production settings

master
ahmetkotan 2019-02-02 03:19:03 +03:00
rodzic 75eaeee9cc
commit 71b7879e98
6 zmienionych plików z 31 dodań i 2 usunięć

3
.gitignore vendored
Wyświetl plik

@ -7,4 +7,5 @@ dist/
*.sqlite3
*.db
static_root/
test.html
test.html
local.py

6
install.sh 100755
Wyświetl plik

@ -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

6
requirements.txt 100644
Wyświetl plik

@ -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

Wyświetl plik

@ -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']
ALLOWED_HOSTS = ip_list

Wyświetl plik

@ -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<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}),
]