luanpoppe
commited on
Commit
·
dd19e1b
1
Parent(s):
064fab7
feat: initial commit
Browse files- .dockerignore +34 -0
- .gitignore +174 -0
- Dockerfile +64 -0
- README.Docker.md +22 -0
- compose.yaml +6 -0
- endpoint_teste/__init__.py +0 -0
- endpoint_teste/admin.py +7 -0
- endpoint_teste/apps.py +6 -0
- endpoint_teste/migrations/0001_initial.py +21 -0
- endpoint_teste/migrations/__init__.py +0 -0
- endpoint_teste/models.py +8 -0
- endpoint_teste/serializer.py +8 -0
- endpoint_teste/tests.py +3 -0
- endpoint_teste/views.py +13 -0
- manage.py +22 -0
- requirements.txt +0 -0
- setup/__init__.py +0 -0
- setup/asgi.py +16 -0
- setup/settings.py +165 -0
- setup/urls.py +29 -0
- setup/wsgi.py +17 -0
- vercel.json +18 -0
.dockerignore
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Include any files or directories that you don't want to be copied to your
|
2 |
+
# container here (e.g., local build artifacts, temporary files, etc.).
|
3 |
+
#
|
4 |
+
# For more help, visit the .dockerignore file reference guide at
|
5 |
+
# https://docs.docker.com/go/build-context-dockerignore/
|
6 |
+
|
7 |
+
**/.DS_Store
|
8 |
+
**/__pycache__
|
9 |
+
**/.venv
|
10 |
+
**/.classpath
|
11 |
+
**/.dockerignore
|
12 |
+
**/.env
|
13 |
+
**/.git
|
14 |
+
**/.gitignore
|
15 |
+
**/.project
|
16 |
+
**/.settings
|
17 |
+
**/.toolstarget
|
18 |
+
**/.vs
|
19 |
+
**/.vscode
|
20 |
+
**/*.*proj.user
|
21 |
+
**/*.dbmdl
|
22 |
+
**/*.jfm
|
23 |
+
**/bin
|
24 |
+
**/charts
|
25 |
+
**/docker-compose*
|
26 |
+
**/compose.y*ml
|
27 |
+
**/Dockerfile*
|
28 |
+
**/node_modules
|
29 |
+
**/npm-debug.log
|
30 |
+
**/obj
|
31 |
+
**/secrets.dev.yaml
|
32 |
+
**/values.dev.yaml
|
33 |
+
LICENSE
|
34 |
+
README.md
|
.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,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# syntax=docker/dockerfile:1
|
2 |
+
|
3 |
+
# Comments are provided throughout this file to help you get started.
|
4 |
+
# If you need more help, visit the Dockerfile reference guide at
|
5 |
+
# https://docs.docker.com/go/dockerfile-reference/
|
6 |
+
|
7 |
+
# Want to help us make this template better? Share your feedback here: https://forms.gle/ybq9Krt8jtBL3iCk7
|
8 |
+
|
9 |
+
ARG PYTHON_VERSION=3.12.4
|
10 |
+
FROM python:${PYTHON_VERSION}-slim AS base
|
11 |
+
|
12 |
+
# Prevents Python from writing pyc files.
|
13 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
14 |
+
|
15 |
+
# Keeps Python from buffering stdout and stderr to avoid situations where
|
16 |
+
# the application crashes without emitting any logs due to buffering.
|
17 |
+
ENV PYTHONUNBUFFERED=1
|
18 |
+
ENV SECRET_KEY=53ng5(^guxf_!l0@5ka(54l!z=wsh0mmlq%v))kr9#%t*vo*&l
|
19 |
+
|
20 |
+
WORKDIR /app
|
21 |
+
|
22 |
+
COPY requirements.txt .
|
23 |
+
|
24 |
+
RUN pip install -r requirements.txt
|
25 |
+
|
26 |
+
COPY . .
|
27 |
+
|
28 |
+
EXPOSE 8000
|
29 |
+
|
30 |
+
# CMD ["python3", "manage.py", "runserver"]
|
31 |
+
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
|
32 |
+
|
33 |
+
# # Create a non-privileged user that the app will run under.
|
34 |
+
# # See https://docs.docker.com/go/dockerfile-user-best-practices/
|
35 |
+
# ARG UID=10001
|
36 |
+
# RUN adduser \
|
37 |
+
# --disabled-password \
|
38 |
+
# --gecos "" \
|
39 |
+
# --home "/nonexistent" \
|
40 |
+
# --shell "/sbin/nologin" \
|
41 |
+
# --no-create-home \
|
42 |
+
# --uid "${UID}" \
|
43 |
+
# appuser
|
44 |
+
|
45 |
+
# # Download dependencies as a separate step to take advantage of Docker's caching.
|
46 |
+
# # Leverage a cache mount to /root/.cache/pip to speed up subsequent builds.
|
47 |
+
# # Leverage a bind mount to requirements.txt to avoid having to copy them into
|
48 |
+
# # into this layer.
|
49 |
+
# RUN --mount=type=cache,target=/root/.cache/pip \
|
50 |
+
# --mount=type=bind,source=requirements.txt,target=requirements.txt \
|
51 |
+
# python -m pip install -r requirements.txt
|
52 |
+
|
53 |
+
# # Switch to the non-privileged user to run the application.
|
54 |
+
# USER appuser
|
55 |
+
|
56 |
+
# # Copy the source code into the container.
|
57 |
+
# COPY . .
|
58 |
+
|
59 |
+
# # Expose the port that the application listens on.
|
60 |
+
# EXPOSE 8000
|
61 |
+
|
62 |
+
# # Run the application.
|
63 |
+
# # CMD gunicorn '.venv.Lib.site-packages.asgiref.wsgi' --bind=0.0.0.0:8000
|
64 |
+
# CMD python manage.py runserver
|
README.Docker.md
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### Building and running your application
|
2 |
+
|
3 |
+
When you're ready, start your application by running:
|
4 |
+
`docker compose up --build`.
|
5 |
+
|
6 |
+
Your application will be available at http://localhost:8000.
|
7 |
+
|
8 |
+
### Deploying your application to the cloud
|
9 |
+
|
10 |
+
First, build your image, e.g.: `docker build -t myapp .`.
|
11 |
+
If your cloud uses a different CPU architecture than your development
|
12 |
+
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
|
13 |
+
you'll want to build the image for that platform, e.g.:
|
14 |
+
`docker build --platform=linux/amd64 -t myapp .`.
|
15 |
+
|
16 |
+
Then, push it to your registry, e.g. `docker push myregistry.com/myapp`.
|
17 |
+
|
18 |
+
Consult Docker's [getting started](https://docs.docker.com/go/get-started-sharing/)
|
19 |
+
docs for more detail on building and pushing.
|
20 |
+
|
21 |
+
### References
|
22 |
+
* [Docker's Python guide](https://docs.docker.com/language/python/)
|
compose.yaml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
services:
|
2 |
+
django-server:
|
3 |
+
image: django-docker:0.0.1
|
4 |
+
build: .
|
5 |
+
ports:
|
6 |
+
- 8000:8000
|
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/0001_initial.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.9 on 2024-08-06 01:09
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
|
8 |
+
initial = True
|
9 |
+
|
10 |
+
dependencies = [
|
11 |
+
]
|
12 |
+
|
13 |
+
operations = [
|
14 |
+
migrations.CreateModel(
|
15 |
+
name='EndpointTesteModel',
|
16 |
+
fields=[
|
17 |
+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
18 |
+
('teste', models.CharField(max_length=300)),
|
19 |
+
],
|
20 |
+
),
|
21 |
+
]
|
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,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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__"
|
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,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from rest_framework import viewsets, filters
|
2 |
+
from django_filters.rest_framework import DjangoFilterBackend
|
3 |
+
|
4 |
+
from endpoint_teste.models import EndpointTesteModel
|
5 |
+
from endpoint_teste.serializer import EndpointTesteSerializer
|
6 |
+
# Create your views here.
|
7 |
+
|
8 |
+
class EndpointTesteViewSet(viewsets.ModelViewSet):
|
9 |
+
"""Mostrará todas as tarefas"""
|
10 |
+
queryset = EndpointTesteModel.objects.order_by("id").all()
|
11 |
+
serializer_class = EndpointTesteSerializer
|
12 |
+
filter_backends = [DjangoFilterBackend, filters.SearchFilter]
|
13 |
+
search_fields = ["id"]
|
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 (624 Bytes). 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,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 = False
|
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 |
+
"http://localhost:8000",
|
157 |
+
"http://localhost:8001",
|
158 |
+
"http://127.0.0.1",
|
159 |
+
"https://127.0.0.1"
|
160 |
+
]
|
161 |
+
|
162 |
+
REST_FRAMEWORK = {
|
163 |
+
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
164 |
+
'PAGE_SIZE': 10
|
165 |
+
}
|
setup/urls.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
URL configuration for setup project.
|
3 |
+
|
4 |
+
The `urlpatterns` list routes URLs to views. For more information please see:
|
5 |
+
https://docs.djangoproject.com/en/4.2/topics/http/urls/
|
6 |
+
Examples:
|
7 |
+
Function views
|
8 |
+
1. Add an import: from my_app import views
|
9 |
+
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
10 |
+
Class-based views
|
11 |
+
1. Add an import: from other_app.views import Home
|
12 |
+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
13 |
+
Including another URLconf
|
14 |
+
1. Import the include() function: from django.urls import include, path
|
15 |
+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
16 |
+
"""
|
17 |
+
from django.contrib import admin
|
18 |
+
from django.urls import path, include
|
19 |
+
from rest_framework import routers
|
20 |
+
|
21 |
+
from endpoint_teste.views import EndpointTesteViewSet
|
22 |
+
|
23 |
+
router = routers.DefaultRouter()
|
24 |
+
router.register("endpoint-teste", EndpointTesteViewSet, basename="Basename do endpoint-teste")
|
25 |
+
|
26 |
+
urlpatterns = [
|
27 |
+
path("admin/", admin.site.urls),
|
28 |
+
path('', include(router.urls)),
|
29 |
+
]
|
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 |
+
}
|