Backend Web Development Project Files
Backend Web Development Project Files
"""
Django settings for hello project.
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'home.apps.HomeConfig',
'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 = 'hello.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 = 'hello.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_URL = 'static/'
#added manually
STATICFILES_DIRS = [os.path.join(BASE_DIR, "templates")]
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
URLS.py
"""hello 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.contrib import admin
from django.urls import path, include
Wsgi.py
"""
WSGI config for hello project.
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hello.settings')
application = get_wsgi_application()
class HomeConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'home'
models.py
from django.db import models
urlpatterns = [
path("", views.index, name="ho"),
path("services", views.services, name="services"),
path("contact", views.contact, name="contact"),
path("about", views.about, name="anout"),
path("awards", views.awards, name="awards"),
path("Education", views.education, name="education"),
path("home", views.home, name="home"),
]
Views.py
from django.shortcuts import render, HttpResponse
from datetime import datetime
from home.models import Contact
from django.http import HttpResponse
from django.contrib import messages
def services(request):
return render(request, 'services.html',)
#return HttpResponse("This is services page")
def contact(request):
if request.method == "POST":
name= request.POST.get('name')
email= request.POST.get('email')
desc= request.POST.get('desc')
contact= Contact(name=name, email=email, desc=desc,
date=datetime.today())
contact.save()
messages.success(request, "Your message has been sent to Ram's
Techverse")
return render(request, 'contact.html',)
#return HttpResponse(contact_text)
def awards(request):
return render(request, 'awards.html')
#return HttpResponse(message)
def about(request):
return render(request, 'about.html')
def education(request):
return render(request, 'education.html')
def home(request):
return render(request, 'index.html')
Templates
Base.html (base file)
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<li class="nav-item">
<a class="nav-link" href="Education">Education <span class="sr-
only">(current)</span></a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search"
placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0"
type="submit">Search</button>
</form>
</div>
</nav>
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message }} alert-dismissible fade show my-0"
role="alert">
<strong>{{ message }}</dtrong>
<button type="button" class="close" data-dismiss="alert" aria-
label="close">
<span aria-hidden="true"> × </span>
</button>
</div>
{% endfor %}
{% endif %}
{% block body %} {% endblock body%}
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-
q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-
UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"
integrity="sha384-
JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
</body>
</html>
Index.html
{% extends 'base.html' %}
{% block title %} Home {% endblock title %}
{% block body %}
<div class="container-fluid px-0">
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css
">
<style>
/* CSS styles for the background image and text */
.background-image {
background-image:
url("https://source.unsplash.com/featured/?electronics");
background-size: cover;
background-position: center;
min-height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.text-dark {
color: #000; /* Default dark text color */
}
</style>
image.onload = function() {
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
const context = canvas.getContext('2d');
context.drawImage(image, 0, 0);
Education.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Curriculum Vitae</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css
">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-8 offset-md-2">
<h1>Curriculum Vitae</h1>
<hr>
<div class="card">
<div class="card-body">
<h5 class="card-title">Kednriya Vidyalaya DLW campus
Varanasi</h5>
<img class="d-block w-50" src="https://i.imgur.com/AGsfY4P.png"
alt="College Image" class="img-fluid">
<p class="card-text">Class 9th to 12th</p>
<ul>
<li>Class 9th: 94%</li>
<li>Class 10th: 96%</li>
<li>Class 11th: 85%</li>
<li>Class 12th: 94.4%</li>
<ul>
</div>
</div>
<hr>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/js/bootstrap.min.js"></scrip
t>
</body>
</html>
Contact.html
{% extends 'base.html' %}
{% block title %} Contact
{% endblock title %}
{% block body %}
<style>
/* CSS styles for the contact information */
.contact-info {
text-align: center;
padding: 20px;
background-color: #f2f2f2;
border-radius: 10px;
animation: fade-in 1s;
}
.contact-info h1 {
color: #333;
font-size: 28px;
margin-bottom: 10px;
}
.contact-info p {
font-size: 18px;
margin-bottom: 5px;
}
.contact-info a {
color: #007bff;
text-decoration: none;
transition: color 0.3s;
}
.contact-info a:hover {
color: #004a99;
}
@keyframes fade-in {
0% { opacity: 0; }
100% { opacity: 1; }
}
</style>
<div class="container-fluid px=0">
<img align="center" src="https://source.unsplash.com/1500x400/?conatct,phone"
class="d-block w-199 mx-0" alt="..." >
<div class="contact-info">
<h1>My Contact Information</h1>
<p>Phone number: 9026646427 </p>
<p>Email: [email protected]</p>
<p>LinkedIn: <a href="https://www.linkedin.com/in/ram-tripathi-94365a257">
Ram's LinkedIn Profile</a></p>
<form method="post" action="/contact">
{% csrf_token %}
<h1>Contact form</h1>
<div class="mb-3">
<label for="name" class="form-label">Your Name</label>
<input type="name" class="form-control" id="name" name="name"
placeholder="Enter Your name">
</div>
<div class="mb-3">
<label for="name" class="form-label">Email Address</label>
<input type="email" class="form-control" id="email" name="email"
placeholder="Enter Your Email">
</div>
<div class="mb-3">
<label for="desc" class="form-label">Your Message/Query</label>
<textarea type="desc" class="form-control" id="desc" rows="3"
name="desc"></textarea>
</div>
<button class= "btn btn-primary" type="submit"> Submit </button>
</form>
</div>
{% endblock body%}
awards.html
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
<link rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css
">
</head>
<body>
<div class="container">
<h2>Reliance Foundation Scholarship</h2>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script
src="https://cdn.jsdelivr.net/npm/[email protected]/js/bootstrap.min.js"></scrip
t>
</body>
</html>
About.html
{% extends 'base.html' %}
{% block title %} About
{% endblock title %}
{% block body %}
<div class="container-fluid px-0">
<div id="carouselExampleIndicators" class="carousel slide" data-
ride="carousel">
<ol class="carousel-indicators">
<li data-target="#carouselExampleIndicators" data-slide-to="0"
class="active"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
<li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
</ol>
<div class="carousel-inner">
<div class="carousel-item active">
<img class="d-block w-75" src="https://i.imgur.com/0qpYL2W.jpg"
alt="first-slide" style="width: 100px; height: auto;">
<div class="carousel-caption d-none d-md-block">
<h5>ECG Machine using esp32 module</h5>
<p>This is me holding an esp32 module powered ECG machine with
its probes attached to me</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://i.imgur.com/zx0BiKH.jpg?1"
alt="Second Slide" style="width: 500px; height: auto;">
<div class="carousel-caption d-none d-md-block">
<h5>CNC Plotter</h5>
<p>CNC machine built using an Arduino with CNC shield</p>
</div>
</div>
<div class="carousel-item">
<img class="d-block w-100" src="https://i.imgur.com/copIXZy.jpg"
alt="Third slide">
<div class="carousel-caption d-none d-md-block">
<h5>Oscilloscope</h5>
<p>This is an Oscilloscopethat i have built using raspberry
pi</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleIndicators"
role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleIndicators"
role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
{% endblock body%}