diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..039e328 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +db.sqlite3 +my-name \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0fc342a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3.8.0 +WORKDIR /code +COPY requirements.txt /code/requirements.txt +RUN pip config set global.index-url http://pypi.tuna.tsinghua.edu.cn/simple +RUN pip config set global.trusted-host pypi.tuna.tsinghua.edu.cn +RUN pip install --upgrade pip +RUN pip install -r requirements.txt +COPY . /code/ \ No newline at end of file diff --git a/demo/__init__.py b/demo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/demo/__pycache__/__init__.cpython-311.pyc b/demo/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..718a0fa Binary files /dev/null and b/demo/__pycache__/__init__.cpython-311.pyc differ diff --git a/demo/__pycache__/__init__.cpython-38.pyc b/demo/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..ed0a751 Binary files /dev/null and b/demo/__pycache__/__init__.cpython-38.pyc differ diff --git a/demo/__pycache__/admin.cpython-311.pyc b/demo/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000..0c72e01 Binary files /dev/null and b/demo/__pycache__/admin.cpython-311.pyc differ diff --git a/demo/__pycache__/admin.cpython-38.pyc b/demo/__pycache__/admin.cpython-38.pyc new file mode 100644 index 0000000..ab11431 Binary files /dev/null and b/demo/__pycache__/admin.cpython-38.pyc differ diff --git a/demo/__pycache__/apps.cpython-311.pyc b/demo/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000..a3443fc Binary files /dev/null and b/demo/__pycache__/apps.cpython-311.pyc differ diff --git a/demo/__pycache__/apps.cpython-38.pyc b/demo/__pycache__/apps.cpython-38.pyc new file mode 100644 index 0000000..c7608fa Binary files /dev/null and b/demo/__pycache__/apps.cpython-38.pyc differ diff --git a/demo/__pycache__/models.cpython-311.pyc b/demo/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000..c8a7bc2 Binary files /dev/null and b/demo/__pycache__/models.cpython-311.pyc differ diff --git a/demo/__pycache__/models.cpython-38.pyc b/demo/__pycache__/models.cpython-38.pyc new file mode 100644 index 0000000..b8ef387 Binary files /dev/null and b/demo/__pycache__/models.cpython-38.pyc differ diff --git a/demo/__pycache__/urls.cpython-311.pyc b/demo/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..cbcd03a Binary files /dev/null and b/demo/__pycache__/urls.cpython-311.pyc differ diff --git a/demo/__pycache__/urls.cpython-38.pyc b/demo/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..85fd596 Binary files /dev/null and b/demo/__pycache__/urls.cpython-38.pyc differ diff --git a/demo/__pycache__/views.cpython-311.pyc b/demo/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000..74bbdf4 Binary files /dev/null and b/demo/__pycache__/views.cpython-311.pyc differ diff --git a/demo/__pycache__/views.cpython-38.pyc b/demo/__pycache__/views.cpython-38.pyc new file mode 100644 index 0000000..a137132 Binary files /dev/null and b/demo/__pycache__/views.cpython-38.pyc differ diff --git a/demo/admin.py b/demo/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/demo/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/demo/apps.py b/demo/apps.py new file mode 100644 index 0000000..d69e874 --- /dev/null +++ b/demo/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class DemoConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'demo' diff --git a/demo/migrations/__init__.py b/demo/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/demo/migrations/__pycache__/__init__.cpython-311.pyc b/demo/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..5f6ee22 Binary files /dev/null and b/demo/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/demo/models.py b/demo/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/demo/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/demo/tests.py b/demo/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/demo/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/demo/urls.py b/demo/urls.py new file mode 100644 index 0000000..37380af --- /dev/null +++ b/demo/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from . import views + + +urlpatterns = [ + path('', views.index, name='index'), +] \ No newline at end of file diff --git a/demo/views.py b/demo/views.py new file mode 100644 index 0000000..94bc318 --- /dev/null +++ b/demo/views.py @@ -0,0 +1,5 @@ +from django.http import HttpResponse + + +def index(request): + return HttpResponse("Hello, world. You're at the polls index.") \ No newline at end of file diff --git a/demoAppDjango/__init__.py b/demoAppDjango/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/demoAppDjango/__pycache__/__init__.cpython-311.pyc b/demoAppDjango/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..8b6111a Binary files /dev/null and b/demoAppDjango/__pycache__/__init__.cpython-311.pyc differ diff --git a/demoAppDjango/__pycache__/__init__.cpython-38.pyc b/demoAppDjango/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..1033eab Binary files /dev/null and b/demoAppDjango/__pycache__/__init__.cpython-38.pyc differ diff --git a/demoAppDjango/__pycache__/settings.cpython-311.pyc b/demoAppDjango/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000..e85d4c1 Binary files /dev/null and b/demoAppDjango/__pycache__/settings.cpython-311.pyc differ diff --git a/demoAppDjango/__pycache__/settings.cpython-38.pyc b/demoAppDjango/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000..20f18e9 Binary files /dev/null and b/demoAppDjango/__pycache__/settings.cpython-38.pyc differ diff --git a/demoAppDjango/__pycache__/urls.cpython-311.pyc b/demoAppDjango/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..00aa087 Binary files /dev/null and b/demoAppDjango/__pycache__/urls.cpython-311.pyc differ diff --git a/demoAppDjango/__pycache__/urls.cpython-38.pyc b/demoAppDjango/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..4ab3797 Binary files /dev/null and b/demoAppDjango/__pycache__/urls.cpython-38.pyc differ diff --git a/demoAppDjango/__pycache__/wsgi.cpython-311.pyc b/demoAppDjango/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..eb34a97 Binary files /dev/null and b/demoAppDjango/__pycache__/wsgi.cpython-311.pyc differ diff --git a/demoAppDjango/__pycache__/wsgi.cpython-38.pyc b/demoAppDjango/__pycache__/wsgi.cpython-38.pyc new file mode 100644 index 0000000..e4c88a9 Binary files /dev/null and b/demoAppDjango/__pycache__/wsgi.cpython-38.pyc differ diff --git a/demoAppDjango/asgi.py b/demoAppDjango/asgi.py new file mode 100644 index 0000000..cd85c4c --- /dev/null +++ b/demoAppDjango/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for demoAppDjango project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demoAppDjango.settings') + +application = get_asgi_application() diff --git a/demoAppDjango/settings.py b/demoAppDjango/settings.py new file mode 100644 index 0000000..2a2b33a --- /dev/null +++ b/demoAppDjango/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for demoAppDjango project. + +Generated by 'django-admin startproject' using Django 4.2.5. + +For more information on this file, see +https://docs.djangoproject.com/en/4.2/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.2/ref/settings/ +""" + +from pathlib import Path + +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-1tur=kj0zz#io&60s37=w4cs)v-1)s6(&su1%o)z2midt6a=iz' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'demo', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'demoAppDjango.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 = 'demoAppDjango.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'db.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.2/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/4.2/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.2/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/demoAppDjango/urls.py b/demoAppDjango/urls.py new file mode 100644 index 0000000..975227a --- /dev/null +++ b/demoAppDjango/urls.py @@ -0,0 +1,22 @@ +""" +URL configuration for demoAppDjango project. + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.2/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.urls import path, include + +urlpatterns = [ + path('', include("demo.urls")) + # path('admin/', admin.site.urls), +] diff --git a/demoAppDjango/wsgi.py b/demoAppDjango/wsgi.py new file mode 100644 index 0000000..15b29fd --- /dev/null +++ b/demoAppDjango/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for demoAppDjango 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/4.2/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demoAppDjango.settings') + +application = get_wsgi_application() diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7df846e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +version: "3" +services: + demoapp: + build: . + container_name: my-name # 容器名,建议用注册的app名称 + command: gunicorn --bind 0.0.0.0:8080 demoAppDjango.wsgi:application + volumes: + - .:/code + - ./my-name/gunicorn:/var/log/gunicorn # 日志文件应该统一管理 + networks: + - shixiong_shixiong_net +networks: + shixiong_shixiong_net: + external: true diff --git a/manage.py b/manage.py new file mode 100644 index 0000000..fa91bce --- /dev/null +++ b/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demoAppDjango.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) + + +if __name__ == '__main__': + main() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f94df9a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,26 @@ +asgiref==3.7.2 +certifi==2023.7.22 +cffi==1.16.0 +charset-normalizer==3.3.1 +cryptography==41.0.5 +Deprecated==1.2.14 +Django==4.2.5 +django-cors-headers==4.3.0 +djangorestframework==3.14.0 +djangorestframework-simplejwt==5.3.1 +gunicorn==21.2.0 +idna==3.4 +jwcrypto==1.5.0 +mysqlclient==2.2.0 +oauthlib==3.2.2 +packaging==23.2 +psycopg2-binary==2.9.9 +pycparser==2.21 +PyJWT==2.8.0 +pytz==2023.3.post1 +requests==2.31.0 +sqlparse==0.4.4 +typing_extensions==4.7.1 +tzdata==2023.3 +urllib3==2.0.7 +wrapt==1.15.0