Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Ajout Server et vscode
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Snell committed Nov 10, 2018
1 parent 21c0c0d commit c3f94e0
Show file tree
Hide file tree
Showing 44 changed files with 399 additions and 126 deletions.
80 changes: 2 additions & 78 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,86 +1,23 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.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
MANIFEST

# 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
# Vscode
.vscode

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# 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
Expand All @@ -89,16 +26,3 @@ venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
File renamed without changes.
3 changes: 3 additions & 0 deletions Serveur/ApiExamAI/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions Serveur/ApiExamAI/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ApiexamaiConfig(AppConfig):
name = 'ApiExamAI'
Empty file.
3 changes: 3 additions & 0 deletions Serveur/ApiExamAI/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
23 changes: 23 additions & 0 deletions Serveur/ApiExamAI/templates/ApiExamAI/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<link rel="stylesheet" href="/media/css/style.css" />
<title>{% block title %}ExamAi{% endblock %}</title>
</head>
<body>
<header>ExamAi</header>
<nav>
{% block nav %}
<ul>
<li><a href="/">Statistiques</a></li>
<li><a href="/blog/">Élève</a></li>
<li><a href="/contact/">Fonctionnement</a></li>
</ul>
{% endblock %}
</nav>
<section id="content">
{% block content %}{% endblock %}
</section>
<footer>&copy; ExamAi, Maitrise, Pierre Snell</footer>
</body>
</html>
3 changes: 3 additions & 0 deletions Serveur/ApiExamAI/templates/ApiExamAI/eleve.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% extends "base.html"%}
<h1>Surveillance en cours</h1>
<p>Le {{date}} élève {{ idul }}</p>
3 changes: 3 additions & 0 deletions Serveur/ApiExamAI/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions Serveur/ApiExamAI/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path, re_path
from . import views

urlpatterns = [
path('accueil', views.home),
path('eleve/<str:idul>', views.view_eleve),
path('articles/<int:year>/<int:month>', views.list_articles),
re_path(r'(?P<idul>^[A-Z]{5}\d{0,2}$)', views.view_eleve, name='eleve')
]
27 changes: 27 additions & 0 deletions Serveur/ApiExamAI/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import Http404
from django.shortcuts import redirect
from datetime import datetime


def list_articles(request, year, month):
if month > 12:
#return redirect(view_eleve, idul='PISNE')
return redirect('eleve', idul='PISNE')
#return redirect("https://www.djangoproject.com")
else :
return HttpResponse(
"Vous avez demandé {0} et {1} !".format(year,month))

def home(request):
return HttpResponse("""
<h1>Bienvenue ExamAi !</h1>
<p>Api : getInfos ou plop </p>
""")

def view_eleve(request, idul):
#return HttpResponse("Vous avez demandé l'eleve {0} !".format(idul))
date = datetime.now()
#eturn render(request, 'ApiExamAI/eleve.html', date)
return render(request, 'ApiExamAI/eleve.html', locals())
Empty file added Serveur/Serveur/__init__.py
Empty file.
123 changes: 123 additions & 0 deletions Serveur/Serveur/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
"""
Django settings for Serveur project.
Generated by 'django-admin startproject' using Django 2.1.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.1/ref/settings/
"""

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__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'xlj&680ss$ewi^tch_u9i&@b#dd1#2=f1!^_p(jk+01y=zy4-f'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ApiExamAI',
]

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 = 'Serveur.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 = 'Serveur.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Password validation
# https://docs.djangoproject.com/en/2.1/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.1/topics/i18n/

LANGUAGE_CODE = 'fr-FR'

TIME_ZONE = 'EST'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/

STATIC_URL = '/static/'
23 changes: 23 additions & 0 deletions Serveur/Serveur/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Serveur URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/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
from django.urls import include

urlpatterns = [
path('admin/', admin.site.urls),
path('ApiExamAI/', include('ApiExamAI.urls')),
]
16 changes: 16 additions & 0 deletions Serveur/Serveur/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Serveur 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.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Serveur.settings')

application = get_wsgi_application()
15 changes: 15 additions & 0 deletions Serveur/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Serveur.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)
Loading

0 comments on commit c3f94e0

Please sign in to comment.