├── db.sqlite3 ├── dictionary ├── __init__.py ├── migrations │ ├── __init__.py │ └── __pycache__ │ │ └── __init__.cpython-310.pyc ├── models.py ├── tests.py ├── admin.py ├── __pycache__ │ ├── admin.cpython-310.pyc │ ├── apps.cpython-310.pyc │ ├── urls.cpython-310.pyc │ ├── views.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ └── models.cpython-310.pyc ├── urls.py ├── apps.py └── views.py ├── runtime.txt ├── englishdictionary ├── __init__.py ├── __pycache__ │ ├── urls.cpython-310.pyc │ ├── wsgi.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ └── settings.cpython-310.pyc ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── Procfile ├── requirements.txt ├── manage.py └── templates ├── index.html └── word.html /db.sqlite3: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /dictionary/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.10.1 -------------------------------------------------------------------------------- /dictionary/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /englishdictionary/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: gunicorn englishdictionary.wsgi:application --log-file - -------------------------------------------------------------------------------- /dictionary/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /dictionary/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /dictionary/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/requirements.txt -------------------------------------------------------------------------------- /dictionary/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /englishdictionary/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/englishdictionary/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /englishdictionary/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/englishdictionary/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | urlpatterns = [ 4 | path('',views.index,name='index'), 5 | path('word',views.word,name='word'), 6 | ] -------------------------------------------------------------------------------- /englishdictionary/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/englishdictionary/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /englishdictionary/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/englishdictionary/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /dictionary/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class DictionaryConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'dictionary' 7 | -------------------------------------------------------------------------------- /dictionary/migrations/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/backendbuilderdev/Django-English-Dictionary/HEAD/dictionary/migrations/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /englishdictionary/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for englishdictionary project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'englishdictionary.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /englishdictionary/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for englishdictionary project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'englishdictionary.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'englishdictionary.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /englishdictionary/urls.py: -------------------------------------------------------------------------------- 1 | """englishdictionary URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path,include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('',include('dictionary.urls')) 22 | ] 23 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 55 | 56 | 57 |
58 | 67 |
68 | 69 | -------------------------------------------------------------------------------- /dictionary/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render,redirect 2 | from PyDictionary import PyDictionary 3 | 4 | from django.contrib import messages 5 | import requests, json 6 | 7 | 8 | # Create your views here. 9 | def index(request): 10 | return render(request, 'index.html') 11 | 12 | def word(request): 13 | if request.method == "POST": 14 | search = request.POST['search'] 15 | search = search.lower() 16 | response = requests.get("https://api.dictionaryapi.dev/api/v2/entries/en/"+search) 17 | obj = response.json() 18 | """dictionary = PyDictionary() 19 | meaning = dictionary.meaning(search) 20 | synonyms = dictionary.synonym(search) 21 | print(synonyms) 22 | antonyms = dictionary.antonym(search)""" 23 | meaning = json.dumps(obj[0]["meanings"][0]["definitions"][0]["definition"], sort_keys=True) 24 | synonyms = [] 25 | for d in obj[0]["meanings"][0]["definitions"]: 26 | for dd in d["synonyms"]: 27 | synonyms.append(json.dumps(dd)) 28 | if len(synonyms)==5: 29 | break 30 | if len(synonyms)==5: 31 | break 32 | antonyms = [] 33 | for d in obj[0]["meanings"][0]["definitions"]: 34 | for dd in d["antonyms"]: 35 | antonyms.append(json.dumps(dd)) 36 | if len(antonyms)==5: 37 | break 38 | if len(antonyms)==5: 39 | break 40 | context = { 41 | 'meaning': meaning, 42 | 'synonyms': synonyms, 43 | 'antonyms': antonyms 44 | } 45 | return render(request, 'word.html', context) 46 | else: 47 | return render(request, 'index.html') 48 | -------------------------------------------------------------------------------- /templates/word.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 67 | 68 | 69 |
70 | 79 | 80 |

Meaning: {{meaning}}

81 | 82 |

Synonyms: {% for synonym in synonyms %} 83 | {{synonym}}, 84 | {% endfor %}

85 | 86 | 87 |

Antonyms: {% for antonym in antonyms %} 88 | {{antonym}}, 89 | {% endfor %}

90 | 91 |
92 |
93 | {% for message in messages %} 94 |
{{ message }}
95 | {% endfor %} 96 |
97 | 98 | 99 | -------------------------------------------------------------------------------- /englishdictionary/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for englishdictionary project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.2.5. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.2/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | import django_heroku 15 | 16 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 17 | BASE_DIR = Path(__file__).resolve().parent.parent 18 | 19 | 20 | # Quick-start development settings - unsuitable for production 21 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ 22 | 23 | # SECURITY WARNING: keep the secret key used in production secret! 24 | SECRET_KEY = 'django-insecure-y!e_yqr_9nsobte4+*qfgh!^e+3ukeh2c$ipjv=p9f=7@!ol4j' 25 | 26 | # SECURITY WARNING: don't run with debug turned on in production! 27 | DEBUG = False 28 | 29 | ALLOWED_HOSTS = ['*'] 30 | 31 | 32 | # Application definition 33 | 34 | INSTALLED_APPS = [ 35 | 'django.contrib.admin', 36 | 'django.contrib.auth', 37 | 'django.contrib.contenttypes', 38 | 'django.contrib.sessions', 39 | 'django.contrib.messages', 40 | 'django.contrib.staticfiles', 41 | 42 | 'dictionary', 43 | ] 44 | 45 | MIDDLEWARE = [ 46 | 'django.middleware.security.SecurityMiddleware', 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | ] 54 | 55 | ROOT_URLCONF = 'englishdictionary.urls' 56 | 57 | TEMPLATES = [ 58 | { 59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 60 | 'DIRS': [BASE_DIR/'templates'], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'englishdictionary.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/3.2/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': BASE_DIR / 'db.sqlite3', 83 | } 84 | } 85 | 86 | 87 | # Password validation 88 | # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 89 | 90 | AUTH_PASSWORD_VALIDATORS = [ 91 | { 92 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 93 | }, 94 | { 95 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 96 | }, 97 | { 98 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 99 | }, 100 | { 101 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 102 | }, 103 | ] 104 | 105 | 106 | # Internationalization 107 | # https://docs.djangoproject.com/en/3.2/topics/i18n/ 108 | 109 | LANGUAGE_CODE = 'en-us' 110 | 111 | TIME_ZONE = 'UTC' 112 | 113 | USE_I18N = True 114 | 115 | USE_L10N = True 116 | 117 | USE_TZ = True 118 | 119 | 120 | # Static files (CSS, JavaScript, Images) 121 | # https://docs.djangoproject.com/en/3.2/howto/static-files/ 122 | 123 | STATIC_URL = '/static/' 124 | django_heroku.settings(locals()) 125 | 126 | # Default primary key field type 127 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field 128 | 129 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 130 | --------------------------------------------------------------------------------