diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..5c98b428 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/Senior_Project.iml b/.idea/Senior_Project.iml new file mode 100644 index 00000000..b9c73e4a --- /dev/null +++ b/.idea/Senior_Project.iml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..6649a8c6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..31a68ee8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 00000000..998d1c00 --- /dev/null +++ b/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + + +def main(): + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Senior_Project.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/static/crawler/api.py b/static/crawler/api.py new file mode 100644 index 00000000..e2e67a23 --- /dev/null +++ b/static/crawler/api.py @@ -0,0 +1,9 @@ +from crawler.models import NewArticle +from rest_framework import viewsets, permissions +from crawler.static.crawler.serializers import ArticleSerializer + + +class ArticleViewSet(viewsets.ModelViewSet): + queryset = NewArticle.objects.all() + permission_classes = [permissions.AllowAny] + serializer_class = ArticleSerializer \ No newline at end of file diff --git a/static/crawler/serializers.py b/static/crawler/serializers.py new file mode 100644 index 00000000..614e9f02 --- /dev/null +++ b/static/crawler/serializers.py @@ -0,0 +1,8 @@ +from rest_framework import serializers +from crawler.models import NewArticle + + +class ArticleSerializer(serializers.ModelSerializer): + class Meta: + model = NewArticle + fields = '__all__' diff --git a/urls.py b/urls.py new file mode 100644 index 00000000..79ec479b --- /dev/null +++ b/urls.py @@ -0,0 +1,7 @@ +from rest_framework import routers +from crawler.static.crawler.api import ArticleViewSet + +router = routers.DefaultRouter() +router.register('api/Articles', ArticleViewSet,'articles') + +urlpatterns = router.urls