Ajout des fichiers.
This commit is contained in:
commit
7d4b079595
17 changed files with 508 additions and 0 deletions
128
.gitignore
vendored
Normal file
128
.gitignore
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/vim,django,python
|
||||
|
||||
### Django ###
|
||||
*.log
|
||||
*.pot
|
||||
*.pyc
|
||||
__pycache__/
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
media
|
||||
|
||||
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
|
||||
# in your Git repository. Update and uncomment the following line accordingly.
|
||||
# <django-project-name>/staticfiles/
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
.pytest_cache/
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
.hypothesis/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# celery beat schedule file
|
||||
celerybeat-schedule.*
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
||||
### Vim ###
|
||||
# swap
|
||||
.sw[a-p]
|
||||
.*.sw[a-p]
|
||||
# session
|
||||
Session.vim
|
||||
# temporary
|
||||
.netrwhist
|
||||
*~
|
||||
# auto-generated tag files
|
||||
tags
|
||||
|
||||
|
||||
# End of https://www.gitignore.io/api/vim,django,python
|
84
deploy.sh
Normal file
84
deploy.sh
Normal file
|
@ -0,0 +1,84 @@
|
|||
#! /bin/bash
|
||||
|
||||
PYTHON_INTERPRETER = "/usr/bin/python3"
|
||||
|
||||
printf "\033[0;32m > Installation de MySQL \033[0m\n"
|
||||
apt-get -y install mysql-client mysql-server
|
||||
printf "\033[0;32m > Installation de Apache \033[0m\n"
|
||||
apt-get -y install apache2 libapache2-mod-wsgi-py3
|
||||
a2enmod ssl
|
||||
a2enmod wsgi
|
||||
printf "\033[0;32m > Installation de Python3 et pip \033[0m\n"
|
||||
apt-get -y install python3 python3-pip
|
||||
pip3 install virtualenv
|
||||
|
||||
printf "\033[0;32m > Création du virtualenv \033[0m\n"
|
||||
virtualenv env_site -p "$PYTHON_INTERPRETER"
|
||||
source env_site/bin/activate
|
||||
|
||||
sudo apt install libmysqlclient-dev
|
||||
pip3 install mysqlclient
|
||||
|
||||
printf "\033[0;32m > Installation des dépendances \033[0m\n"
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
printf "\033[0;32m > Génération de la secret_key \033[0m\n"
|
||||
|
||||
django_secret_key=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(50)]))")
|
||||
|
||||
cp site_tps/settings_local.example.py site_tps/settings_local.py
|
||||
sed -i 's/SUPER_SECRET_KEY/'"$django_secret_key"'/g' site_tps/settings_local.py
|
||||
|
||||
printf "\033[0;32m > Configuration de MySQL \033[0m\n"
|
||||
sql_name="festart"
|
||||
sql_login="festart"
|
||||
sql_host="localhost"
|
||||
sql_password=$(python -c "import random; print(''.join([random.SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789%=+') for i in range(10)]))")
|
||||
|
||||
mysql_command="CREATE DATABASE $sql_name collate='utf8_general_ci';
|
||||
CREATE USER '$sql_login'@'localhost' IDENTIFIED BY '$sql_password';
|
||||
GRANT ALL PRIVILEGES ON $sql_name.* TO '$sql_login'@'localhost';
|
||||
FLUSH PRIVILEGES;"
|
||||
|
||||
echo "$mysql_command"
|
||||
|
||||
mysql -u root --execute="$mysql_command" -p
|
||||
|
||||
|
||||
sed -i 's/db_engine/django.db.backends.mysql/g' site_tps/settings_local.py
|
||||
sed -i 's/db_name/'"$sql_name"'/g' site_tps/settings_local.py
|
||||
sed -i 's/db_user/'"$sql_login"'/g' site_tps/settings_local.py
|
||||
sed -i 's/db_pass/'"$sql_password"'/g' site_tps/settings_local.py
|
||||
sed -i 's/db_host/'"$sql_host"'/g' site_tps/settings_local.py
|
||||
|
||||
#printf "\033[0;32m > Configuration des mails \033[0m\n"
|
||||
|
||||
#read -p "Domaine d'envoi des mails > " domain_name
|
||||
#read -p "Mail de l'administrateur > " admin_mail
|
||||
|
||||
printf "\033[0;32m > Domaine\033[0m\n"
|
||||
read -p "Domaine autorisé > " url_server
|
||||
sed -i 's,URL_SERVER,'"$url_server"',g' site_tps/settings_local.py
|
||||
|
||||
printf "\033[0;32m > settings_local.py créé \033[0m\n"
|
||||
|
||||
printf "\033[0;32m > Export du wsgi.py de production \033[0m\n"
|
||||
cp wsgi_prod.py site_tps/wsgi.py
|
||||
current_path=$(pwd)
|
||||
sed -i 's,INSTALL_PATH,'"$current_path"',g' site_tps/wsgi.py
|
||||
|
||||
printf "\033[0;32m > Configuration de Apache \033[0m\n"
|
||||
cp site_tps.conf /etc/apache2/sites-available
|
||||
sed -i 's,URL_SERVER,'"$url_server"',g' /etc/apache2/sites-available/site_tps.conf
|
||||
sed -i 's,INSTALL_PATH,'"$current_path"',g' /etc/apache2/sites-available/site_tps.conf
|
||||
a2ensite site_tps
|
||||
rm /etc/apache2/sites-enabled/000-default.conf
|
||||
service apache2 reload
|
||||
|
||||
|
||||
printf "\033[0;32m > Application des migrations \033[0m\n"
|
||||
python manage.py migrate
|
||||
printf "\033[0;32m > Collecte des statiques \033[0m\n"
|
||||
python manage.py collectstatic
|
||||
printf "\033[0;32m > Création d'un super utilisateur\033[0m\n"
|
||||
python manage.py createsuperuser
|
0
live_share_youtube/__init__.py
Normal file
0
live_share_youtube/__init__.py
Normal file
114
live_share_youtube/settings.py
Normal file
114
live_share_youtube/settings.py
Normal file
|
@ -0,0 +1,114 @@
|
|||
"""
|
||||
Django settings for site_tps project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 2.0.1.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.0/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/2.0/ref/settings/
|
||||
"""
|
||||
|
||||
import os
|
||||
from .settings_local import *
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'bootstrap4',
|
||||
'player',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'live_share_youtube.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [os.path.join(BASE_DIR, 'templates')],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
WSGI_APPLICATION = 'live_share_youtube.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#databases
|
||||
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/2.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'fr-fr'
|
||||
|
||||
TIME_ZONE = 'Europe/Paris'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_L10N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.0/howto/static-files/
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'static', 'media')
|
||||
|
||||
LOGIN_REDIRECT_URL = "/"
|
||||
LOGOUT_REDIRECT_URL = "/"
|
48
live_share_youtube/settings_local.example.py
Normal file
48
live_share_youtube/settings_local.example.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
SECRET_KEY = 'SUPER_SECRET_KEY'
|
||||
|
||||
DB_PASSWORD = 'db_pass'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
|
||||
# ADMINS = [('My Beloved Administrator', 'admin_mail')]
|
||||
|
||||
# SERVER_EMAIL = 'no-reply@example.org'
|
||||
|
||||
# Obligatoire, liste des host autorisés
|
||||
ALLOWED_HOSTS = ['URL_SERVER']
|
||||
|
||||
if not DEBUG:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'db_engine',
|
||||
'NAME': 'db_name',
|
||||
'USER': 'db_user',
|
||||
'PASSWORD': DB_PASSWORD,
|
||||
'HOST': 'db_host',
|
||||
},
|
||||
}
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
# Security settings, à activer une fois https en place
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = False
|
||||
SECURE_BROWSER_XSS_FILTER = False
|
||||
SESSION_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
X_FRAME_OPTIONS = 'DENY'
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||
|
||||
# EMAIL_HOST = 'MY_EMAIL_HOST'
|
||||
# EMAIL_PORT = MY_EMAIL_PORT
|
48
live_share_youtube/settings_local.py
Normal file
48
live_share_youtube/settings_local.py
Normal file
|
@ -0,0 +1,48 @@
|
|||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
SECRET_KEY = 'zcnwv22hbhfxnzg25n+w7e9a4o98jwj284r9uq5j9y88u9yy74'
|
||||
|
||||
DB_PASSWORD = ''
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
|
||||
# ADMINS = [('My Beloved Administrator', 'admin_mail')]
|
||||
|
||||
# SERVER_EMAIL = 'no-reply@example.org'
|
||||
|
||||
# Obligatoire, liste des host autorisés
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
if not DEBUG:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'live_share_youtube',
|
||||
'USER': 'live_share_youtube',
|
||||
'PASSWORD': DB_PASSWORD,
|
||||
'HOST': 'localhost',
|
||||
},
|
||||
}
|
||||
else:
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
# Security settings, à activer une fois https en place
|
||||
SECURE_CONTENT_TYPE_NOSNIFF = False
|
||||
SECURE_BROWSER_XSS_FILTER = False
|
||||
SESSION_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_SECURE = False
|
||||
CSRF_COOKIE_HTTPONLY = False
|
||||
X_FRAME_OPTIONS = 'DENY'
|
||||
SESSION_COOKIE_AGE = 60 * 60 * 3
|
||||
|
||||
# EMAIL_HOST = 'MY_EMAIL_HOST'
|
||||
# EMAIL_PORT = MY_EMAIL_PORT
|
21
live_share_youtube/urls.py
Normal file
21
live_share_youtube/urls.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
"""live_share_youtube URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/2.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
]
|
16
live_share_youtube/wsgi.py
Normal file
16
live_share_youtube/wsgi.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
"""
|
||||
WSGI config for live_share_youtube project.
|
||||
|
||||
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "live_share_youtube.settings")
|
||||
|
||||
application = get_wsgi_application()
|
15
manage.py
Executable file
15
manage.py
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "live_share_youtube.settings")
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
"available on your PYTHONPATH environment variable? Did you "
|
||||
"forget to activate a virtual environment?"
|
||||
) from exc
|
||||
execute_from_command_line(sys.argv)
|
0
player/__init__.py
Normal file
0
player/__init__.py
Normal file
3
player/admin.py
Normal file
3
player/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
5
player/apps.py
Normal file
5
player/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PlayerConfig(AppConfig):
|
||||
name = 'player'
|
0
player/migrations/__init__.py
Normal file
0
player/migrations/__init__.py
Normal file
3
player/models.py
Normal file
3
player/models.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
3
player/tests.py
Normal file
3
player/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
3
player/views.py
Normal file
3
player/views.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
17
wsgi_prod.py
Normal file
17
wsgi_prod.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
|
||||
# Activation de l'environnement virtuel
|
||||
activate_env=os.path.join('INSTALL_PATH/env_site', 'bin/activate_this.py')
|
||||
exec(compile(open(activate_env, "rb").read(), activate_env, 'exec'), {'__file__':activate_env})
|
||||
|
||||
# Ajout du répertoire du site au PATH
|
||||
sys.path.append('INSTALL_PATH')
|
||||
sys.path.append('INSTALL_PATH/site_tps')
|
||||
|
||||
# Les trucs par défaut de Django
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "site_tps.settings")
|
||||
application = get_wsgi_application()
|
Loading…
Reference in a new issue