luanpoppe commited on
Commit
e63103b
·
1 Parent(s): 0db9367

initial commit

Browse files
.dockerignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .venv
.gitattributes DELETED
@@ -1,35 +0,0 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by https://www.toptal.com/developers/gitignore/api/django
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=django
3
+
4
+ ### Django ###
5
+ *.log
6
+ *.pot
7
+ *.pyc
8
+ __pycache__/
9
+ local_settings.py
10
+ db.sqlite3
11
+ db.sqlite3-journal
12
+ media
13
+
14
+ # If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
15
+ # in your Git repository. Update and uncomment the following line accordingly.
16
+ # <django-project-name>/staticfiles/
17
+
18
+ ### Django.Python Stack ###
19
+ # Byte-compiled / optimized / DLL files
20
+ *.py[cod]
21
+ *$py.class
22
+
23
+ # C extensions
24
+ *.so
25
+
26
+ # Distribution / packaging
27
+ .Python
28
+ build/
29
+ develop-eggs/
30
+ dist/
31
+ downloads/
32
+ eggs/
33
+ .eggs/
34
+ lib/
35
+ lib64/
36
+ parts/
37
+ sdist/
38
+ var/
39
+ wheels/
40
+ share/python-wheels/
41
+ *.egg-info/
42
+ .installed.cfg
43
+ *.egg
44
+ MANIFEST
45
+
46
+ # PyInstaller
47
+ # Usually these files are written by a python script from a template
48
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
49
+ *.manifest
50
+ *.spec
51
+
52
+ # Installer logs
53
+ pip-log.txt
54
+ pip-delete-this-directory.txt
55
+
56
+ # Unit test / coverage reports
57
+ htmlcov/
58
+ .tox/
59
+ .nox/
60
+ .coverage
61
+ .coverage.*
62
+ .cache
63
+ nosetests.xml
64
+ coverage.xml
65
+ *.cover
66
+ *.py,cover
67
+ .hypothesis/
68
+ .pytest_cache/
69
+ cover/
70
+
71
+ # Translations
72
+ *.mo
73
+
74
+ # Django stuff:
75
+
76
+ # Flask stuff:
77
+ instance/
78
+ .webassets-cache
79
+
80
+ # Scrapy stuff:
81
+ .scrapy
82
+
83
+ # Sphinx documentation
84
+ docs/_build/
85
+
86
+ # PyBuilder
87
+ .pybuilder/
88
+ target/
89
+
90
+ # Jupyter Notebook
91
+ .ipynb_checkpoints
92
+
93
+ # IPython
94
+ profile_default/
95
+ ipython_config.py
96
+
97
+ # pyenv
98
+ # For a library or package, you might want to ignore these files since the code is
99
+ # intended to run in multiple environments; otherwise, check them in:
100
+ # .python-version
101
+
102
+ # pipenv
103
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
104
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
105
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
106
+ # install all needed dependencies.
107
+ #Pipfile.lock
108
+
109
+ # poetry
110
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
111
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
112
+ # commonly ignored for libraries.
113
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
114
+ #poetry.lock
115
+
116
+ # pdm
117
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
118
+ #pdm.lock
119
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
120
+ # in version control.
121
+ # https://pdm.fming.dev/#use-with-ide
122
+ .pdm.toml
123
+
124
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
125
+ __pypackages__/
126
+
127
+ # Celery stuff
128
+ celerybeat-schedule
129
+ celerybeat.pid
130
+
131
+ # SageMath parsed files
132
+ *.sage.py
133
+
134
+ # Environments
135
+ .env
136
+ .venv
137
+ env/
138
+ venv/
139
+ ENV/
140
+ env.bak/
141
+ venv.bak/
142
+
143
+ # Spyder project settings
144
+ .spyderproject
145
+ .spyproject
146
+
147
+ # Rope project settings
148
+ .ropeproject
149
+
150
+ # mkdocs documentation
151
+ /site
152
+
153
+ # mypy
154
+ .mypy_cache/
155
+ .dmypy.json
156
+ dmypy.json
157
+
158
+ # Pyre type checker
159
+ .pyre/
160
+
161
+ # pytype static type analyzer
162
+ .pytype/
163
+
164
+ # Cython debug symbols
165
+ cython_debug/
166
+
167
+ # PyCharm
168
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
169
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
170
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
171
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
172
+ #.idea/
173
+
174
+ # End of https://www.toptal.com/developers/gitignore/api/django
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.12
2
+
3
+ COPY . ./app
4
+
5
+ WORKDIR /app
6
+
7
+ RUN pip install -r requirements.txt
8
+
9
+ # RUN python3 -m venv /app/.venv
10
+
11
+ # RUN source .venv/bin/activate
12
+ # RUN .venv/bin/activate
13
+
14
+ # ENV PATH="/.venv/bin:$PATH"
15
+
16
+ RUN pip install uvicorn
17
+ CMD ["uvicorn", "setup.asgi:application", "--host", "0.0.0.0", "--port", "7860"]
18
+
19
+ # ENTRYPOINT ["python", "manage.py", "runserver"]
20
+
21
+ # CMD ls /usr/lib/python3.12/site-packages/Lib/site-packages
22
+ # CMD pip freeze
README.md CHANGED
Binary files a/README.md and b/README.md differ
 
compose.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ services:
2
+ projeto-y:
3
+ build: .
4
+ ports:
5
+ - "9000:7860"
6
+ environment:
7
+ - SECRET_KEY=${SECRET_KEY}
8
+ - DATABASE_PASSWORD=${DATABASE_PASSWORD}
9
+ - OPENAI_API_KEY=${OPENAI_API_KEY}
10
+ # - PYTHONPATH=/app:$PYTHONPATH
11
+ env_file:
12
+ - .env
13
+ volumes:
14
+ - type: bind
15
+ source: .venv
16
+ target: /app/.venv
17
+ # target: /usr/lib/python3.12/site-packages
18
+ volumes:
19
+ myapp:
20
+ # watch:
21
+ # develop:
22
+ # watch:
23
+ # - action: sync
24
+ # path: ./
25
+ # target: /app
26
+ # ignore:
27
+ # - .venv/
28
+ # - action: rebuild
29
+ # path: requirements.txt
30
+ # - action: rebuild
31
+ # path: .venv/
endpoint_teste/__init__.py ADDED
File without changes
endpoint_teste/admin.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from django.contrib import admin
2
+
3
+ from endpoint_teste.models import EndpointTesteModel
4
+
5
+ # Register your models here.
6
+
7
+ admin.site.register(EndpointTesteModel)
endpoint_teste/apps.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class EndpointTesteConfig(AppConfig):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "endpoint_teste"
endpoint_teste/migrations/__init__.py ADDED
File without changes
endpoint_teste/models.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from django.db import models
2
+
3
+ # Create your models here.
4
+ class EndpointTesteModel(models.Model):
5
+ teste = models.CharField(blank=False, max_length=300)
6
+
7
+ def __str__(self):
8
+ return self.teste
endpoint_teste/serializer.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from rest_framework import serializers
2
+
3
+ from endpoint_teste.models import EndpointTesteModel
4
+
5
+ class EndpointTesteSerializer(serializers.ModelSerializer):
6
+ class Meta:
7
+ model = EndpointTesteModel
8
+ fields = "__all__"
9
+
10
+ class TesteSerializer(serializers.Serializer):
11
+ system_prompt = serializers.CharField(required=True)
12
+ history_chat = serializers.ListField(read_only=True, required=False)
13
+ user_message = serializers.CharField(required=True)
14
+ pdf_url = serializers.CharField(required=False)
endpoint_teste/tests.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.test import TestCase
2
+
3
+ # Create your tests here.
endpoint_teste/views.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from rest_framework import viewsets, filters
2
+ from django_filters.rest_framework import DjangoFilterBackend
3
+ from endpoint_teste.models import EndpointTesteModel
4
+ from endpoint_teste.serializer import EndpointTesteSerializer
5
+
6
+ from rest_framework.decorators import api_view
7
+ from rest_framework.response import Response
8
+
9
+ from langchain_backend.main import get_llm_answer
10
+ from .serializer import TesteSerializer
11
+
12
+ class EndpointTesteViewSet(viewsets.ModelViewSet):
13
+ """Mostrará todas as tarefas"""
14
+ queryset = EndpointTesteModel.objects.order_by("id").all()
15
+ serializer_class = EndpointTesteSerializer
16
+ filter_backends = [DjangoFilterBackend, filters.SearchFilter]
17
+ search_fields = ["id"]
18
+
19
+ @api_view(["GET", "POST"])
20
+ def getTeste(request):
21
+ if request.method == "POST":
22
+ serializer = TesteSerializer(data=request.data)
23
+ if serializer.is_valid(raise_exception=True):
24
+ data = request.data
25
+ pdf_url = None
26
+ if data["pdf_url"]:
27
+ pdf_url = data["pdf_url"]
28
+ resposta_llm = get_llm_answer(data["system_prompt"], data["user_message"], pdf_url)
29
+ return Response({
30
+ "Resposta": resposta_llm
31
+ })
langchain_backend/__init__.py ADDED
File without changes
langchain_backend/main.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from langchain_backend.utils import create_prompt_llm_chain, create_retriever, getPDF
3
+ from langchain.chains import create_retrieval_chain
4
+
5
+ os.environ.get("OPENAI_API_KEY")
6
+
7
+ def get_llm_answer(system_prompt, user_prompt, pdf_url):
8
+ pages = None
9
+ if pdf_url:
10
+ pages = getPDF(pdf_url)
11
+ else:
12
+ pages = getPDF()
13
+ retriever = create_retriever(pages)
14
+ rag_chain = create_retrieval_chain(retriever, create_prompt_llm_chain(system_prompt))
15
+ results = rag_chain.invoke({"input": user_prompt})
16
+ return results
langchain_backend/utils.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from langchain_community.document_loaders import PyPDFLoader
2
+ import os
3
+ from langchain_openai import ChatOpenAI
4
+ from langchain_chroma import Chroma
5
+ from langchain_openai import OpenAIEmbeddings
6
+ from langchain_text_splitters import RecursiveCharacterTextSplitter
7
+ from langchain.chains.combine_documents import create_stuff_documents_chain
8
+ from langchain_core.prompts import ChatPromptTemplate
9
+
10
+ os.environ.get("OPENAI_API_KEY")
11
+
12
+ def getPDF(file_path="./nike.pdf"):
13
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
14
+ loader = PyPDFLoader(file_path, extract_images=False)
15
+ pages = loader.load_and_split(text_splitter)
16
+ return pages
17
+
18
+ def create_retriever(documents):
19
+ vectorstore = Chroma.from_documents(
20
+ documents,
21
+ embedding=OpenAIEmbeddings(),
22
+ )
23
+
24
+ retriever = vectorstore.as_retriever(
25
+ search_type="similarity",
26
+ search_kwargs={"k": 1},
27
+ )
28
+
29
+ return retriever
30
+
31
+ def create_prompt_llm_chain(system_prompt):
32
+ model = ChatOpenAI(model="gpt-4o-mini")
33
+
34
+ system_prompt = system_prompt + "\n\n" + "{context}"
35
+ prompt = ChatPromptTemplate.from_messages(
36
+ [
37
+ ("system", system_prompt),
38
+ ("human", "{input}"),
39
+ ]
40
+ )
41
+ question_answer_chain = create_stuff_documents_chain(model, prompt)
42
+ return question_answer_chain
manage.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Django's command-line utility for administrative tasks."""
3
+ import os
4
+ import sys
5
+
6
+
7
+ def main():
8
+ """Run administrative tasks."""
9
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "setup.settings")
10
+ try:
11
+ from django.core.management import execute_from_command_line
12
+ except ImportError as exc:
13
+ raise ImportError(
14
+ "Couldn't import Django. Are you sure it's installed and "
15
+ "available on your PYTHONPATH environment variable? Did you "
16
+ "forget to activate a virtual environment?"
17
+ ) from exc
18
+ execute_from_command_line(sys.argv)
19
+
20
+
21
+ if __name__ == "__main__":
22
+ main()
requirements.txt ADDED
Binary file (5.4 kB). View file
 
setup/__init__.py ADDED
File without changes
setup/asgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ASGI config for setup project.
3
+
4
+ It exposes the ASGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.asgi import get_asgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "setup.settings")
15
+
16
+ application = get_asgi_application()
setup/settings.py ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pathlib import Path, os
2
+ from dotenv import load_dotenv
3
+
4
+ load_dotenv()
5
+
6
+ """
7
+ Django settings for setup project.
8
+
9
+ Generated by 'django-admin startproject' using Django 4.2.9.
10
+
11
+ For more information on this file, see
12
+ https://docs.djangoproject.com/en/4.2/topics/settings/
13
+
14
+ For the full list of settings and their values, see
15
+ https://docs.djangoproject.com/en/4.2/ref/settings/
16
+ """
17
+
18
+ from pathlib import Path
19
+
20
+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
21
+ BASE_DIR = Path(__file__).resolve().parent.parent
22
+
23
+
24
+ # Quick-start development settings - unsuitable for production
25
+ # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
26
+
27
+ # SECURITY WARNING: keep the secret key used in production secret!
28
+ SECRET_KEY = os.environ['SECRET_KEY']
29
+
30
+ # SECURITY WARNING: don't run with debug turned on in production!
31
+ DEBUG = True
32
+
33
+ ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
34
+
35
+
36
+ # Application definition
37
+
38
+ INSTALLED_APPS = [
39
+ "django.contrib.admin",
40
+ "django.contrib.auth",
41
+ "django.contrib.contenttypes",
42
+ "django.contrib.sessions",
43
+ "django.contrib.messages",
44
+ "django.contrib.staticfiles",
45
+ "rest_framework",
46
+ "django_filters",
47
+ "corsheaders",
48
+ "endpoint_teste"
49
+ ]
50
+
51
+ MIDDLEWARE = [
52
+ "corsheaders.middleware.CorsMiddleware",
53
+ "django.middleware.security.SecurityMiddleware",
54
+ "django.contrib.sessions.middleware.SessionMiddleware",
55
+ "django.middleware.common.CommonMiddleware",
56
+ "django.middleware.csrf.CsrfViewMiddleware",
57
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
58
+ "django.contrib.messages.middleware.MessageMiddleware",
59
+ "django.middleware.clickjacking.XFrameOptionsMiddleware",
60
+ ]
61
+
62
+ ROOT_URLCONF = "setup.urls"
63
+
64
+ TEMPLATES = [
65
+ {
66
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
67
+ "DIRS": [],
68
+ "APP_DIRS": True,
69
+ "OPTIONS": {
70
+ "context_processors": [
71
+ "django.template.context_processors.debug",
72
+ "django.template.context_processors.request",
73
+ "django.contrib.auth.context_processors.auth",
74
+ "django.contrib.messages.context_processors.messages",
75
+ ],
76
+ },
77
+ },
78
+ ]
79
+
80
+ WSGI_APPLICATION = "setup.wsgi.application"
81
+
82
+
83
+ # Database
84
+ # https://docs.djangoproject.com/en/4.2/ref/settings/#databases
85
+
86
+ # DATABASES = {
87
+ # 'default': {
88
+ # 'ENGINE': 'django.db.backends.postgresql',
89
+ # 'NAME': "...",
90
+ # 'USER': "...",
91
+ # 'PASSWORD': os.environ['DATABASE_PASSWORD'],
92
+ # 'HOST': "...",
93
+ # 'PORT': 5432,
94
+ # 'OPTIONS': {
95
+ # 'sslmode': 'require',
96
+ # }
97
+ # }
98
+ # }
99
+
100
+ # Se quiser utilizar a database inicial padrão do Django --> SQLite
101
+ DATABASES = {
102
+ "default": {
103
+ "ENGINE": "django.db.backends.sqlite3",
104
+ "NAME": BASE_DIR / "db.sqlite3",
105
+ }
106
+ }
107
+
108
+
109
+ # Password validation
110
+ # https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
111
+
112
+ AUTH_PASSWORD_VALIDATORS = [
113
+ {
114
+ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
115
+ },
116
+ {
117
+ "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
118
+ },
119
+ {
120
+ "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
121
+ },
122
+ {
123
+ "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
124
+ },
125
+ ]
126
+
127
+
128
+ # Internationalization
129
+ # https://docs.djangoproject.com/en/4.2/topics/i18n/
130
+
131
+ LANGUAGE_CODE = "pt-br"
132
+
133
+ TIME_ZONE = "America/Sao_Paulo"
134
+
135
+ USE_I18N = True
136
+
137
+ USE_TZ = True
138
+
139
+
140
+ # Static files (CSS, JavaScript, Images)
141
+ # https://docs.djangoproject.com/en/4.2/howto/static-files/
142
+
143
+ STATIC_URL = "static/"
144
+
145
+ # Default primary key field type
146
+ # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
147
+
148
+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
149
+
150
+ CORS_ORIGIN_WHITELIST = [
151
+ "http://localhost"
152
+ # "http://localhost:5000",
153
+ # "https://luan-pessoal.vercel.app",
154
+ # "http://localhost:5173",
155
+ ]
156
+
157
+ REST_FRAMEWORK = {
158
+ 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
159
+ 'PAGE_SIZE': 10
160
+ }
setup/urls.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.contrib import admin
2
+ from django.urls import path, include
3
+ from rest_framework import routers
4
+
5
+ from endpoint_teste.views import EndpointTesteViewSet
6
+ from endpoint_teste.views import getTeste
7
+
8
+ router = routers.DefaultRouter()
9
+ # router.register("endpoint-teste", EndpointTesteViewSet, basename="Basename do endpoint-teste")
10
+
11
+ urlpatterns = [
12
+ path("admin/", admin.site.urls),
13
+ path('', include(router.urls)),
14
+
15
+ path("teste", getTeste)
16
+ ]
setup/wsgi.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ WSGI config for setup project.
3
+
4
+ It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.wsgi import get_wsgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "setup.settings")
15
+
16
+ application = get_wsgi_application()
17
+ app = application
vercel.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builds": [
3
+ {
4
+ "src": "setup/wsgi.py",
5
+ "use": "@vercel/python",
6
+ "config": {
7
+ "maxLambdaSize": "15mb",
8
+ "runtime": "python3.9"
9
+ }
10
+ }
11
+ ],
12
+ "routes": [
13
+ {
14
+ "src": "/(.*)",
15
+ "dest": "setup/wsgi.py"
16
+ }
17
+ ]
18
+ }