Skip to content

Commit

Permalink
Merge pull request #38 from ruanclaudio/add-drf
Browse files Browse the repository at this point in the history
task add Django Rest Framework
  • Loading branch information
ivancrneto authored May 2, 2024
2 parents 02ac3d7 + 2152837 commit a86db54
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from users.services import Credentials
from users.services import CredentialsService
from webapp.secrets import get_secret
from rest_framework import permissions, viewsets
from rest_framework.decorators import api_view, schema
from rest_framework.response import Response

os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1"
SCOPES = [
Expand Down Expand Up @@ -102,3 +105,7 @@ def google_calendar_redirect_view(request):
return render(request, "core/error.html")
else:
return render(request, "core/success.html")

@api_view(['GET'])
def test_drf(request):
return Response({"message": "Hello for today! See you tomorrow!"})
2 changes: 1 addition & 1 deletion webapp/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def get_secret(secret_name, region_name="sa-east-1"):
except Exception as e_:
raise e_

return json.loads(json.loads(get_secret_value_response['SecretString'])['credentials'])
return json.loads(json.loads(get_secret_value_response['SecretString'])['credentials'])
1 change: 1 addition & 0 deletions webapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"django.contrib.staticfiles",
"core",
"users",
'rest_framework',
]

MIDDLEWARE = [
Expand Down
4 changes: 3 additions & 1 deletion webapp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from django.conf import settings
from django.contrib import admin
from django.urls import path
from django.urls import path, include
from django.views.generic import TemplateView

from core import views
Expand All @@ -32,4 +32,6 @@
path("", views.home, name="home"),
path("privacidade/", TemplateView.as_view(template_name='core/privacy.html')),
path("termos/", TemplateView.as_view(template_name='core/terms.html')),
path('api-auth/', include('rest_framework.urls')),
path('test-drf/', views.test_drf, name="test-drf"),
]

0 comments on commit a86db54

Please sign in to comment.