From 4c903863b35a9dde0b6afbd3d40d6b67aaafc4a1 Mon Sep 17 00:00:00 2001 From: ianjward Date: Mon, 27 Jan 2020 09:10:04 -0800 Subject: [PATCH 1/3] Default PyCharm Django project. --- .idea/.gitignore | 2 + .idea/Senior_Project.iml | 31 +++++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 7 + .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + Senior_Project/__init__.py | 0 Senior_Project/asgi.py | 16 +++ Senior_Project/settings.py | 121 ++++++++++++++++++ Senior_Project/urls.py | 21 +++ Senior_Project/wsgi.py | 16 +++ manage.py | 21 +++ 12 files changed, 255 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Senior_Project.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Senior_Project/__init__.py create mode 100644 Senior_Project/asgi.py create mode 100644 Senior_Project/settings.py create mode 100644 Senior_Project/urls.py create mode 100644 Senior_Project/wsgi.py create mode 100644 manage.py 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/Senior_Project/__init__.py b/Senior_Project/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/Senior_Project/asgi.py b/Senior_Project/asgi.py new file mode 100644 index 00000000..887c33e4 --- /dev/null +++ b/Senior_Project/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for Senior_Project project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Senior_Project.settings') + +application = get_asgi_application() diff --git a/Senior_Project/settings.py b/Senior_Project/settings.py new file mode 100644 index 00000000..69362c9f --- /dev/null +++ b/Senior_Project/settings.py @@ -0,0 +1,121 @@ +""" +Django settings for Senior_Project project. + +Generated by 'django-admin startproject' using Django 3.0.2. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/3.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '_+^&cmf_6c^$lw78he=#l-ry!5mg3^nh=--b$6f53n_*w&&2#1' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'Senior_Project.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'templates')] + , + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'Senior_Project.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/3.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/3.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/3.0/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/Senior_Project/urls.py b/Senior_Project/urls.py new file mode 100644 index 00000000..ef3f4de8 --- /dev/null +++ b/Senior_Project/urls.py @@ -0,0 +1,21 @@ +"""Senior_Project URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/3.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +urlpatterns = [ + path('admin/', admin.site.urls), +] diff --git a/Senior_Project/wsgi.py b/Senior_Project/wsgi.py new file mode 100644 index 00000000..ea1e36a1 --- /dev/null +++ b/Senior_Project/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for Senior_Project project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Senior_Project.settings') + +application = get_wsgi_application() 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() From f1a8db5566c44ab4f8acfe5898bd1e48b02c4f45 Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Sun, 1 Mar 2020 20:57:07 -0800 Subject: [PATCH 2/3] initial --- Senior_Project/__init__.py | 0 Senior_Project/asgi.py | 16 ----- Senior_Project/settings.py | 121 ------------------------------------- Senior_Project/urls.py | 21 ------- Senior_Project/wsgi.py | 16 ----- 5 files changed, 174 deletions(-) delete mode 100644 Senior_Project/__init__.py delete mode 100644 Senior_Project/asgi.py delete mode 100644 Senior_Project/settings.py delete mode 100644 Senior_Project/urls.py delete mode 100644 Senior_Project/wsgi.py diff --git a/Senior_Project/__init__.py b/Senior_Project/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/Senior_Project/asgi.py b/Senior_Project/asgi.py deleted file mode 100644 index 887c33e4..00000000 --- a/Senior_Project/asgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -ASGI config for Senior_Project project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ -""" - -import os - -from django.core.asgi import get_asgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Senior_Project.settings') - -application = get_asgi_application() diff --git a/Senior_Project/settings.py b/Senior_Project/settings.py deleted file mode 100644 index 69362c9f..00000000 --- a/Senior_Project/settings.py +++ /dev/null @@ -1,121 +0,0 @@ -""" -Django settings for Senior_Project project. - -Generated by 'django-admin startproject' using Django 3.0.2. - -For more information on this file, see -https://docs.djangoproject.com/en/3.0/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.0/ref/settings/ -""" - -import os - -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) -BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - - -# Quick-start development settings - unsuitable for production -# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '_+^&cmf_6c^$lw78he=#l-ry!5mg3^nh=--b$6f53n_*w&&2#1' - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True - -ALLOWED_HOSTS = [] - - -# Application definition - -INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', -] - -MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', -] - -ROOT_URLCONF = 'Senior_Project.urls' - -TEMPLATES = [ - { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')] - , - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - ], - }, - }, -] - -WSGI_APPLICATION = 'Senior_Project.wsgi.application' - - -# Database -# https://docs.djangoproject.com/en/3.0/ref/settings/#databases - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), - } -} - - -# Password validation -# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators - -AUTH_PASSWORD_VALIDATORS = [ - { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', - }, - { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', - }, -] - - -# Internationalization -# https://docs.djangoproject.com/en/3.0/topics/i18n/ - -LANGUAGE_CODE = 'en-us' - -TIME_ZONE = 'UTC' - -USE_I18N = True - -USE_L10N = True - -USE_TZ = True - - -# Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/3.0/howto/static-files/ - -STATIC_URL = '/static/' diff --git a/Senior_Project/urls.py b/Senior_Project/urls.py deleted file mode 100644 index ef3f4de8..00000000 --- a/Senior_Project/urls.py +++ /dev/null @@ -1,21 +0,0 @@ -"""Senior_Project URL Configuration - -The `urlpatterns` list routes URLs to views. For more information please see: - https://docs.djangoproject.com/en/3.0/topics/http/urls/ -Examples: -Function views - 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: path('', views.home, name='home') -Class-based views - 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') -Including another URLconf - 1. Import the include() function: from django.urls import include, path - 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) -""" -from django.contrib import admin -from django.urls import path - -urlpatterns = [ - path('admin/', admin.site.urls), -] diff --git a/Senior_Project/wsgi.py b/Senior_Project/wsgi.py deleted file mode 100644 index ea1e36a1..00000000 --- a/Senior_Project/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for Senior_Project project. - -It exposes the WSGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Senior_Project.settings') - -application = get_wsgi_application() From 790b9f58c164b95b73009455a8c984a054e1524a Mon Sep 17 00:00:00 2001 From: Ian Ward Date: Sun, 8 Mar 2020 22:41:55 -0700 Subject: [PATCH 3/3] Added api --- static/crawler/api.py | 9 +++++++++ static/crawler/serializers.py | 8 ++++++++ urls.py | 7 +++++++ 3 files changed, 24 insertions(+) create mode 100644 static/crawler/api.py create mode 100644 static/crawler/serializers.py create mode 100644 urls.py 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