kopia lustrzana https://github.com/ahmetkotan/restpi
added installation and production settings
rodzic
75eaeee9cc
commit
71b7879e98
|
@ -7,4 +7,5 @@ dist/
|
|||
*.sqlite3
|
||||
*.db
|
||||
static_root/
|
||||
test.html
|
||||
test.html
|
||||
local.py
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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}),
|
||||
]
|
||||
|
|
Ładowanie…
Reference in New Issue