티스토리 뷰
(macOS)[python][django][RaspberryPi] ERP platform - SECRET_KEY 보안설정
jinozpersona 2021. 4. 14. 17:281. django SECRET_KEY 보안설정
(pyERP)testerp$ nano config/settings.py
....
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '[YourKey]'
....
(pyERP)testerp$ nano secret.json
(pyERP)testerp$ touch secret.json
(pyERP)$ pip install django
{
"SECRET_KEY": "[YourKey]"
}
(pyERP)testerp$ nano config/settings.py
import os, json
from django.core.exceptions import ImproperlyConfigured
....
secret_file = os.path.join(BASE_DIR,'secret.json')
with open(secret_file) as f:
secret = json.loads(f.read())
def get_secret(setting, secret=secret):
try:
return secret[setting]
except KeyError:
raise ImproperlyConfigured(error_msg)
SECRET_KEY = get_secret("SECRET_KEY")
....
(pyERP)testerp$ ./manage.py runserver
browser localhost:8000 확인
2. git push/pull
(pyERP)testerp$ nano .gitignore
secret.json 추가
.DS_Store
db.sqlite3
*.pyc
__pycache__/
secret.json
git push
[macOS](pyERP)testerp$ git init
[macOS](pyERP)pyERP git:(master)$ git add .
[macOS](pyERP)pyERP git:(master)$ git commit -m "testerp 2nd commit : secret key"
[macOS](pyERP)pyERP git:(master)$ git remote add origin https://github.com/YourRepoName.git
[macOS](pyERP)pyERP git:(master)$ git push -f origin master
git pull/fetch
[Raspi](pyERP)testerp$ git init
[Raspi](pyERP)pyERP git:(master)$ git remote add origin https://github.com/YourRepoName.git
[Raspi](pyERP)testerp$ git pull
[Raspi](pyERP)testerp$ git status
[Raspi](pyERP)testerp$ git fetch --all
Fetching origin
Username for 'https://github.com': [YourGitHubID]
Password for 'https://[YourID]@github.com': [YourGitHubPass]
[Raspi](pyERP)testerp$ git reset --hard origin/master
[Raspi](pyERP)testerp$ git status
SECRET_KEY 적용
[Raspi](pyERP)testerp$ touch secret.json
[Raspi](pyERP)testerp$ nano secret.json
{
"SECRET_KEY": "[YourKey]"
}
[Raspi](pyERP)testerp$ nano config/settings.py
#ALLOWED_HOSTS = ['localhost']
ALLOWED_HOSTS = ['[RaspiIP]']
[Raspi](pyERP)testerp$ uwsgi --ini testerp.ini
server django 구동 확인
'python > django_ERP1' 카테고리의 다른 글
(macOS)[python][django][RaspberryPi] ERP platform - 2 (0) | 2021.04.19 |
---|---|
(macOS)[python][django][RaspberryPi] ERP platform - 1 (0) | 2021.04.15 |
(macOS)[python][django][RaspberryPi] ERP platform - local/server Test (0) | 2021.04.14 |
(macOS)[python][django][RaspberryPi] ERP platform - git (0) | 2021.04.07 |
(macOS)[Raspberry Pi] wi-fi 설정 및 ssh 접속 - 기존 환경 접속 (0) | 2021.03.26 |
- Total
- Today
- Yesterday
- Django
- 확진
- Python
- CSV
- MacOS
- 자가격리
- git
- SSH
- Raspberry Pi
- 라즈베리파이
- github
- analysis
- template
- Regression
- vscode
- 코로나
- COVID-19
- raspberrypi
- pyserial
- DS18B20
- 코로나19
- ERP
- arduino
- sublime text
- Pandas
- server
- Templates
- r
- Model
- DAQ
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |