diff --git a/pollsapi/.gitignore b/pollsapi/.gitignore index 6f67cf1..c5769f7 100644 --- a/pollsapi/.gitignore +++ b/pollsapi/.gitignore @@ -1,3 +1,8 @@ *.pyc db.sqlite3 __pycache__ + +# Elastic Beanstalk Files +.elasticbeanstalk/* +!.elasticbeanstalk/*.cfg.yml +!.elasticbeanstalk/*.global.yml diff --git a/pollsapi/Dockerfile b/pollsapi/Dockerfile new file mode 100644 index 0000000..ba5bcb9 --- /dev/null +++ b/pollsapi/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.9.0 + +ENV PYTHONUNBUFFERED 1 + +RUN mkdir /code + +WORKDIR /code + +COPY requirements.txt /code/ + +RUN pip install -r requirements.txt + +COPY . /code/ + +ENTRYPOINT ["python3", "manage.py"] + +CMD ["runserver", "0.0.0.0:8800"] + diff --git a/pollsapi/polls/.ebextensions/django.config b/pollsapi/polls/.ebextensions/django.config new file mode 100644 index 0000000..527b10f --- /dev/null +++ b/pollsapi/polls/.ebextensions/django.config @@ -0,0 +1,3 @@ +option_settings: + aws:elasticbeanstalk:container:python: + WSGIPath: pollsapi.wsgi:application \ No newline at end of file diff --git a/pollsapi/polls/apiviews.py b/pollsapi/polls/apiviews.py index a85c88a..dd84ea5 100644 --- a/pollsapi/polls/apiviews.py +++ b/pollsapi/polls/apiviews.py @@ -4,6 +4,8 @@ from rest_framework.response import Response from rest_framework import viewsets from rest_framework.exceptions import PermissionDenied +from rest_framework.decorators import api_view, permission_classes +from rest_framework.permissions import AllowAny, IsAuthenticated from django.contrib.auth import authenticate @@ -64,3 +66,7 @@ def post(self, request,): else: return Response({"error": "Wrong Credentials"}, status=status.HTTP_400_BAD_REQUEST) +class MyOwnView(APIView): + @permission_classes([AllowAny]) + def get(self, request): + return Response({'some': 'data'}) \ No newline at end of file diff --git a/pollsapi/polls/urls.py b/pollsapi/polls/urls.py index d3eb535..26aabf5 100644 --- a/pollsapi/polls/urls.py +++ b/pollsapi/polls/urls.py @@ -1,6 +1,6 @@ from django.urls import path -from .apiviews import PollViewSet, ChoiceList, CreateVote, UserCreate, LoginView +from .apiviews import PollViewSet, ChoiceList, CreateVote, UserCreate, LoginView, MyOwnView from rest_framework.routers import DefaultRouter @@ -22,6 +22,7 @@ path("polls//choices//vote/", CreateVote.as_view(), name="polls_list"), path(r'docs/', include_docs_urls(title='Polls API')), path(r'swagger-docs/', schema_view), + path('my-own-view/', MyOwnView.as_view(), name = "demo") ] urlpatterns += router.urls diff --git a/pollsapi/pollsapi/settings.py b/pollsapi/pollsapi/settings.py index 0486e4c..0dbcea3 100644 --- a/pollsapi/pollsapi/settings.py +++ b/pollsapi/pollsapi/settings.py @@ -25,7 +25,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ["*"] REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': (