소스 검색

add django rest framework server

pull/2/head
Guillaume Vincent 9 년 전
부모
커밋
28c69965cb
13개의 변경된 파일212개의 추가작업 그리고 1개의 파일을 삭제
  1. +60
    -1
      .gitignore
  2. +0
    -0
      server/lesspass/__init__.py
  3. +0
    -0
      server/lesspass/api/__init__.py
  4. +3
    -0
      server/lesspass/api/admin.py
  5. +0
    -0
      server/lesspass/api/migrations/__init__.py
  6. +3
    -0
      server/lesspass/api/models.py
  7. +3
    -0
      server/lesspass/api/tests.py
  8. +3
    -0
      server/lesspass/api/views.py
  9. +90
    -0
      server/lesspass/settings.py
  10. +21
    -0
      server/lesspass/urls.py
  11. +16
    -0
      server/lesspass/wsgi.py
  12. +10
    -0
      server/manage.py
  13. +3
    -0
      server/requirements.txt

+ 60
- 1
.gitignore 파일 보기

@@ -26,4 +26,63 @@ build/Release
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
.idea
dist
dist
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.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
nosetests.xml
coverage.xml
*,cover

# Translations
*.mo
*.pot

# Django stuff:
*.log

# Sphinx documentation
docs/_build/

# PyBuilder
target/
/server/db.sqlite3

+ 0
- 0
server/lesspass/__init__.py 파일 보기


+ 0
- 0
server/lesspass/api/__init__.py 파일 보기


+ 3
- 0
server/lesspass/api/admin.py 파일 보기

@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.

+ 0
- 0
server/lesspass/api/migrations/__init__.py 파일 보기


+ 3
- 0
server/lesspass/api/models.py 파일 보기

@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.

+ 3
- 0
server/lesspass/api/tests.py 파일 보기

@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.

+ 3
- 0
server/lesspass/api/views.py 파일 보기

@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.

+ 90
- 0
server/lesspass/settings.py 파일 보기

@@ -0,0 +1,90 @@
import os

from smartconfigparser import Config

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

CONFIG_PATH = os.path.join(BASE_DIR, 'config')
if not os.path.exists(CONFIG_PATH):
os.makedirs(CONFIG_PATH)

CONFIG_FILE = os.path.join(CONFIG_PATH, 'config.ini')
config = Config()
config.read(CONFIG_FILE)

try:
SECRET_KEY = config.get('DJANGO', 'SECRET_KEY')
except:
print('SECRET_KEY not found! Generating a new one...')
import random

SECRET_KEY = "".join([random.choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$^&*(-_=+)") for i in range(50)])
if not config.has_section('DJANGO'):
config.add_section('DJANGO')
config.set('DJANGO', 'SECRET_KEY', SECRET_KEY)
with open(CONFIG_FILE, 'wt') as f:
config.write(f)

DEBUG = config.getboolean('DJANGO', 'DEBUG', False)

ALLOWED_HOSTS = config.getlist('DJANGO', 'ALLOWED_HOSTS', ['localhost', '127.0.0.1', '*.oslab.fr'])

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)

ROOT_URLCONF = 'lesspass.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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 = 'lesspass.wsgi.application'


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

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_URL = '/static/'

+ 21
- 0
server/lesspass/urls.py 파일 보기

@@ -0,0 +1,21 @@
"""lesspass URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]

+ 16
- 0
server/lesspass/wsgi.py 파일 보기

@@ -0,0 +1,16 @@
"""
WSGI config for lesspass 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/1.8/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lesspass.settings")

application = get_wsgi_application()

+ 10
- 0
server/manage.py 파일 보기

@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lesspass.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

+ 3
- 0
server/requirements.txt 파일 보기

@@ -0,0 +1,3 @@
Django==1.8.7
djangorestframework==3.3.2
smartconfigparser==0.1.1

불러오는 중...
취소
저장