Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EyadShabrawy committed Jan 19, 2023
0 parents commit b4a7713
Show file tree
Hide file tree
Showing 170 changed files with 31,093 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
keys.env
Binary file added db.sqlite3
Binary file not shown.
22 changes: 22 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.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()
Empty file added mysite/__init__.py
Empty file.
Binary file added mysite/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added mysite/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file added mysite/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added mysite/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions mysite/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for mysite 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/4.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

application = get_asgi_application()
130 changes: 130 additions & 0 deletions mysite/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
"""
Django settings for mysite project.
Generated by 'django-admin startproject' using Django 4.1.5.
For more information on this file, see
https://docs.djangoproject.com/en/4.1/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.1/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-$)g-vl@t-9fg*4@9rryqye%8*7p6d8$xuh=!xsexh)xgo7=j@j'

# 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',
'pages'
]

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 = 'mysite.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [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 = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/4.1/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/4.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR / 'pages' / 'templates' / 'pages' / 'static']





# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
20 changes: 20 additions & 0 deletions mysite/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""mysite URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.1/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.urls import path, include

urlpatterns = [
path('', include('pages.urls')),
]
16 changes: 16 additions & 0 deletions mysite/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for mysite 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/4.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')

application = get_wsgi_application()
Empty file added pages/__init__.py
Empty file.
Binary file added pages/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added pages/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added pages/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file added pages/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file added pages/__pycache__/openai_api.cpython-39.pyc
Binary file not shown.
Binary file added pages/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added pages/__pycache__/views.cpython-39.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions pages/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions pages/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PagesConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'pages'
Empty file added pages/migrations/__init__.py
Empty file.
Binary file added pages/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions pages/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
23 changes: 23 additions & 0 deletions pages/openai_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import requests

def generate_answer(prompt, api_key):
headers = {
'Content-Type': 'application/json',
'Authorization': f'Bearer {api_key}'
}
data = {
"prompt": prompt,
"model": "text-davinci-002",
"max_tokens":100,
"stop":"."
}

resp = requests.post('https://api.openai.com/v1/completions', headers=headers, json=data)

if resp.status_code != 200:
raise ValueError("Failed to generate answer "+resp.text)

return resp.json()['choices'][0]['text']



26 changes: 26 additions & 0 deletions pages/templates/pages/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% extends 'pages\base.html' %}

{% block content %}
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'about.css' %}">
<section class="about-section">
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1 class="mt-5">About AI Writer</h1>
<p class="lead">AI Writer is a cutting-edge technology that utilizes artificial intelligence to assist in the writing process. It is capable of generating written content on a wide range of topics with a high level of coherence and readability. AI Writer can be used for a variety of applications such as content creation for websites, article writing, essay writing, and even creative writing. It can also be used to paraphrase and summarize existing texts, making it a valuable tool for content optimization. With the ability to understand the nuances of human language and adapt to different writing styles, AI Writer is set to revolutionize the way we create and consume written content. It will help users to save time and effort, and also to get better results.</p>
<div class="row">
<div class="col-md-4 mx-auto">
<div class="card text-center">
<img src="https://i.imgur.com/96pT5dd.jpeg" alt="Team Member">
<h2>Eyad ElShabrawy</h2>
<p>Founder</p>
</div>
</div>
</div>
</div>
</div>
</div>
</section>

{% endblock %}
75 changes: 75 additions & 0 deletions pages/templates/pages/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{% load static %}
<!DOCTYPE html>
<html>
<head>
<style>
/* html, body {
height: 100%;
}
footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
} */


footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: 100%;
}

</style>
</style>
<link rel="stylesheet" type="text/css" href="{% static 'base.css' %}">
<meta charset="UTF-8">
<title>{% block title %} AI Writer {% endblock %}</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">AI Writer</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="{% url 'home' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'essay_writing' %}">Essay Writing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'paraphrase' %}">Paraphraser</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'about' %}">About</a>
</li>
</ul>
</div>
</nav>
{% block content %}{% endblock %}

<div class="container">
<footer class="bg-dark text-white p-4">
<div class="row">
<div class="col-md-6">
<p>Copyright &copy; 2023 AI-Writer.co</p>
</div>
<div class="col-md-6">
<div class="d-flex justify-content-end">
<a href="#" class="text-white mr-4">Facebook</a>
<a href="#" class="text-white mr-4">Twitter</a>
<a href="#" class="text-white">Instagram</a>
</div>
</div>
</div>
</footer>
</div>

</body>
</html>
Loading

0 comments on commit b4a7713

Please sign in to comment.