Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/test api #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pollsapi/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*.pyc
db.sqlite3
__pycache__

# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
18 changes: 18 additions & 0 deletions pollsapi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

3 changes: 3 additions & 0 deletions pollsapi/polls/.ebextensions/django.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: pollsapi.wsgi:application
6 changes: 6 additions & 0 deletions pollsapi/polls/apiviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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'})
3 changes: 2 additions & 1 deletion pollsapi/polls/urls.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -22,6 +22,7 @@
path("polls/<int:pk>/choices/<int:choice_pk>/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
2 changes: 1 addition & 1 deletion pollsapi/pollsapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': (
Expand Down