diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..294fd98 Binary files /dev/null and b/.DS_Store differ diff --git a/database.sqlite3 b/database.sqlite3 new file mode 100644 index 0000000..8bc883c Binary files /dev/null and b/database.sqlite3 differ diff --git a/frame/.DS_Store b/frame/.DS_Store new file mode 100644 index 0000000..da9c6b3 Binary files /dev/null and b/frame/.DS_Store differ diff --git a/frame/__init__.py b/frame/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/frame/__pycache__/__init__.cpython-310.pyc b/frame/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..fcc99a4 Binary files /dev/null and b/frame/__pycache__/__init__.cpython-310.pyc differ diff --git a/frame/__pycache__/__init__.cpython-311.pyc b/frame/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..050f13a Binary files /dev/null and b/frame/__pycache__/__init__.cpython-311.pyc differ diff --git a/frame/__pycache__/settings.cpython-310.pyc b/frame/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000..a875346 Binary files /dev/null and b/frame/__pycache__/settings.cpython-310.pyc differ diff --git a/frame/__pycache__/settings.cpython-311.pyc b/frame/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000..9f9e9ac Binary files /dev/null and b/frame/__pycache__/settings.cpython-311.pyc differ diff --git a/frame/__pycache__/urls.cpython-310.pyc b/frame/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..02bf8a4 Binary files /dev/null and b/frame/__pycache__/urls.cpython-310.pyc differ diff --git a/frame/__pycache__/urls.cpython-311.pyc b/frame/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..d7c8b2e Binary files /dev/null and b/frame/__pycache__/urls.cpython-311.pyc differ diff --git a/frame/__pycache__/wsgi.cpython-310.pyc b/frame/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000..b9a7afc Binary files /dev/null and b/frame/__pycache__/wsgi.cpython-310.pyc differ diff --git a/frame/__pycache__/wsgi.cpython-311.pyc b/frame/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000..9d53601 Binary files /dev/null and b/frame/__pycache__/wsgi.cpython-311.pyc differ diff --git a/frame/asgi.py b/frame/asgi.py new file mode 100644 index 0000000..0f369f1 --- /dev/null +++ b/frame/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for frame 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.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'frame.settings') + +application = get_asgi_application() diff --git a/frame/settings.py b/frame/settings.py new file mode 100644 index 0000000..f086ead --- /dev/null +++ b/frame/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for frame project. + +Generated by 'django-admin startproject' using Django 4.1.7. + +For more information on this file, see +https://docs.djangoproject.com/en/4.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/4.1/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.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-j&$q6hwwc$!k=h0yk*jl*r&6%mwgwsu$uv+=u00d$39i-c_8&5' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ['84.201.188.44', '127.0.0.1'] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'wrapper', +] + +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 = 'frame.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 = 'frame.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/4.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': BASE_DIR / 'database.sqlite3', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/4.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/4.1/topics/i18n/ + +LANGUAGE_CODE = 'ru-ru' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/4.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' diff --git a/frame/urls.py b/frame/urls.py new file mode 100644 index 0000000..78b80f2 --- /dev/null +++ b/frame/urls.py @@ -0,0 +1,29 @@ +"""frame URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/4.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 include, path +from wrapper import views as wv +from wrapper import services as fun + +urlpatterns = [ + path('', include('wrapper.urls')), + path('admin/', admin.site.urls, name='admin'), +] + +for v in wv.views: + urlpatterns.append(path(f'{v.__name__}/', v, name=f'{v.__name__}')) + + diff --git a/frame/wsgi.py b/frame/wsgi.py new file mode 100644 index 0000000..6adcde2 --- /dev/null +++ b/frame/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for frame 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.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'frame.settings') + +application = get_wsgi_application() diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..e56c1b9 --- /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', 'frame.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/wrapper/.DS_Store b/wrapper/.DS_Store new file mode 100644 index 0000000..0d2c153 Binary files /dev/null and b/wrapper/.DS_Store differ diff --git a/wrapper/__init__.py b/wrapper/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wrapper/__pycache__/__init__.cpython-310.pyc b/wrapper/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..494077c Binary files /dev/null and b/wrapper/__pycache__/__init__.cpython-310.pyc differ diff --git a/wrapper/__pycache__/__init__.cpython-311.pyc b/wrapper/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..931cd24 Binary files /dev/null and b/wrapper/__pycache__/__init__.cpython-311.pyc differ diff --git a/wrapper/__pycache__/admin.cpython-310.pyc b/wrapper/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000..18534af Binary files /dev/null and b/wrapper/__pycache__/admin.cpython-310.pyc differ diff --git a/wrapper/__pycache__/admin.cpython-311.pyc b/wrapper/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000..abc3512 Binary files /dev/null and b/wrapper/__pycache__/admin.cpython-311.pyc differ diff --git a/wrapper/__pycache__/apps.cpython-310.pyc b/wrapper/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000..6d499ad Binary files /dev/null and b/wrapper/__pycache__/apps.cpython-310.pyc differ diff --git a/wrapper/__pycache__/apps.cpython-311.pyc b/wrapper/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000..a1562ac Binary files /dev/null and b/wrapper/__pycache__/apps.cpython-311.pyc differ diff --git a/wrapper/__pycache__/forms.cpython-310.pyc b/wrapper/__pycache__/forms.cpython-310.pyc new file mode 100644 index 0000000..38f9735 Binary files /dev/null and b/wrapper/__pycache__/forms.cpython-310.pyc differ diff --git a/wrapper/__pycache__/functions.cpython-310.pyc b/wrapper/__pycache__/functions.cpython-310.pyc new file mode 100644 index 0000000..f64c48e Binary files /dev/null and b/wrapper/__pycache__/functions.cpython-310.pyc differ diff --git a/wrapper/__pycache__/models.cpython-310.pyc b/wrapper/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000..ad7278f Binary files /dev/null and b/wrapper/__pycache__/models.cpython-310.pyc differ diff --git a/wrapper/__pycache__/models.cpython-311.pyc b/wrapper/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000..37c4026 Binary files /dev/null and b/wrapper/__pycache__/models.cpython-311.pyc differ diff --git a/wrapper/__pycache__/services.cpython-310.pyc b/wrapper/__pycache__/services.cpython-310.pyc new file mode 100644 index 0000000..d09cd86 Binary files /dev/null and b/wrapper/__pycache__/services.cpython-310.pyc differ diff --git a/wrapper/__pycache__/services.cpython-311.pyc b/wrapper/__pycache__/services.cpython-311.pyc new file mode 100644 index 0000000..5c7acce Binary files /dev/null and b/wrapper/__pycache__/services.cpython-311.pyc differ diff --git a/wrapper/__pycache__/types.cpython-310.pyc b/wrapper/__pycache__/types.cpython-310.pyc new file mode 100644 index 0000000..f3a37f5 Binary files /dev/null and b/wrapper/__pycache__/types.cpython-310.pyc differ diff --git a/wrapper/__pycache__/types.cpython-311.pyc b/wrapper/__pycache__/types.cpython-311.pyc new file mode 100644 index 0000000..e5c44e8 Binary files /dev/null and b/wrapper/__pycache__/types.cpython-311.pyc differ diff --git a/wrapper/__pycache__/urls.cpython-310.pyc b/wrapper/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000..6cfa782 Binary files /dev/null and b/wrapper/__pycache__/urls.cpython-310.pyc differ diff --git a/wrapper/__pycache__/urls.cpython-311.pyc b/wrapper/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000..af0d81f Binary files /dev/null and b/wrapper/__pycache__/urls.cpython-311.pyc differ diff --git a/wrapper/__pycache__/views.cpython-310.pyc b/wrapper/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000..d8e08dc Binary files /dev/null and b/wrapper/__pycache__/views.cpython-310.pyc differ diff --git a/wrapper/__pycache__/views.cpython-311.pyc b/wrapper/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000..46c99f4 Binary files /dev/null and b/wrapper/__pycache__/views.cpython-311.pyc differ diff --git a/wrapper/admin.py b/wrapper/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/wrapper/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/wrapper/apps.py b/wrapper/apps.py new file mode 100644 index 0000000..c17b4f6 --- /dev/null +++ b/wrapper/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class WrapperConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'wrapper' diff --git a/wrapper/forms.py b/wrapper/forms.py new file mode 100644 index 0000000..c7c5b78 --- /dev/null +++ b/wrapper/forms.py @@ -0,0 +1,5 @@ +from django import forms + +class GeeksForm(forms.Form): + name = forms.CharField() + geeks_field = forms.FileField() \ No newline at end of file diff --git a/wrapper/migrations/__init__.py b/wrapper/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wrapper/migrations/__pycache__/__init__.cpython-310.pyc b/wrapper/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..51bac58 Binary files /dev/null and b/wrapper/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/wrapper/migrations/__pycache__/__init__.cpython-311.pyc b/wrapper/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000..9d4fcfd Binary files /dev/null and b/wrapper/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/wrapper/models.py b/wrapper/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/wrapper/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/wrapper/services.py b/wrapper/services.py new file mode 100644 index 0000000..da1e952 --- /dev/null +++ b/wrapper/services.py @@ -0,0 +1,20 @@ +from typing import IO +from .types import File + + +def mnk(): + return "Это результат" + +from .types import Text + +def n100(): + return sum(range(100)) + +def f(a: File): + return a.decode('utf8') + +def ff(a: int, b: int): + return a + b + +def fff(a: int, b: int, c: int, d: int, e: int,): + return a + b + c + d + e \ No newline at end of file diff --git a/wrapper/templates/home.html b/wrapper/templates/home.html new file mode 100644 index 0000000..34a2bfb --- /dev/null +++ b/wrapper/templates/home.html @@ -0,0 +1,137 @@ + + + + + + + + + Sticky Footer Navbar Template · Bootstrap v5.2 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+

Sticky footer with fixed navbar

+

Pin a footer to the bottom of the viewport in desktop browsers with this custom HTML and CSS. A fixed navbar has been added with padding-top: 60px; on the main > .container.

+

Back to the default sticky footer minus the navbar.

+
+
+ + + + + + + + + \ No newline at end of file diff --git a/wrapper/templates/login.html b/wrapper/templates/login.html new file mode 100644 index 0000000..a94a29e --- /dev/null +++ b/wrapper/templates/login.html @@ -0,0 +1,119 @@ + + + + + + + + + Signin Template · Bootstrap v5.2 + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {% csrf_token %} + +

Please sign in

+ +
+ + +
+
+ + +
+ +
+ +
+ +

© 2017–2022

+
+
+{% if message %} +

{{ message }}

+{% endif %} + + + + + \ No newline at end of file diff --git a/wrapper/templates/trial.html b/wrapper/templates/trial.html new file mode 100644 index 0000000..e2897af --- /dev/null +++ b/wrapper/templates/trial.html @@ -0,0 +1,142 @@ + + + + + + + Document + + + + + +

+ Теперь здесь можно удобно добавлять любой ваш сервис с любым количеством полей! Пользуйтесь! +

+
+ {% csrf_token %} + {{ form.as_table }} + +
+
+ +
+ + \ No newline at end of file diff --git a/wrapper/tests.py b/wrapper/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/wrapper/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/wrapper/types.py b/wrapper/types.py new file mode 100644 index 0000000..c7cbb5e --- /dev/null +++ b/wrapper/types.py @@ -0,0 +1,5 @@ +class Text(str): + pass + +class File(): + pass \ No newline at end of file diff --git a/wrapper/urls.py b/wrapper/urls.py new file mode 100644 index 0000000..1bff905 --- /dev/null +++ b/wrapper/urls.py @@ -0,0 +1,8 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('login/', views.login_view, name='login'), + path('home/', views.home, name='home'), +] + diff --git a/wrapper/views.py b/wrapper/views.py new file mode 100644 index 0000000..32c14c8 --- /dev/null +++ b/wrapper/views.py @@ -0,0 +1,79 @@ +from __future__ import annotations +from django.shortcuts import render +from django.http import HttpResponse +from django.http import HttpResponseRedirect +from django.contrib.auth import authenticate, login +from urllib import request +from django import forms +from django.db import models +from copy import copy +from . import services +from .types import Text, File +from .forms import GeeksForm + +views = [] + +def args(f): + return(f.__annotations__) + +def field(s, i): + print(type(s)) + if (s == int): + return forms.IntegerField(label = i) + if (s == str): + return forms.CharField(label = i) + if (s == Text): + return forms.CharField(label = i, widget=forms.Textarea) + + +def wrap(f): + def my_view(request): + arguments = copy(args(f)) + temp = {} + for i in arguments: + if (arguments[i] == File): + temp[i] = forms.FileField() + else: + temp[i] = field(arguments[i], i) + + if (request.method == 'POST'): + form = type('MyF', (forms.Form, ), temp)() + for i in arguments.keys(): + types = copy(f.__annotations__) + if (types[i] != File): + arguments[i] = types[i](request.POST[i]) + else: + arguments[i] = request.FILES['a'].read() + res = f(**arguments) + + #в f передаем словарь + else: + form = type('MyF', (forms.Form, ), temp)() + res = None + return render(request, 'trial.html', {'form': form, 'res': str(res)}) + my_view.__name__ = f.__name__ + return my_view + + +for n in dir(services): + if "_" not in n: + views.append(wrap(getattr(services, n))) + + +def login_view(request): + if request.method == 'POST': + username = request.POST['username'] + password = request.POST['password'] + user = authenticate(request, username=username, password=password) + if user is not None: + login(request, user) + return redirect('home') + else: + message = 'Invalid login credentials' + else: + message = '' + return render(request, 'login.html', {'message': message}) + + +def home(request): + return render(request, 'home.html') \ No newline at end of file