Professional Documents
Culture Documents
Full Stack
Full Stack
FRONT-END DEVELOPMENT
Flask : It is a web application framework which is written in python
It is considered as micro-framework
Some of the popular web applications frameworks are :
flask,django,pyramid,cherrypy
Flask was developed by armin
Flask is designed based on WSGI(web server gateway interface) toolkit in jinja2
template engine
Default port number --> 5000
URL to access flask application ---> http://127.0.0.1:5000
WSGI Toolkit : It is a toolkit used for python web application development
It acts as an interface between web server and web application
Jinja2 : It is a web template engine
It combines a template with a certain data source/code to render a dynamic web
page
Web pages : static web page and dynamic web page
Flask environment set-up:
python with version 2.7 above
To install flask : pip install flask
1st Web Application (Flask) :
from flask import Flask
app=Flask(__name__)
@app.route("/")
def sample():
return "Welcome to flask"
#dynamic routing
@app.route("/<name>")
def sample1(name):
return f'Hi {name}'
if __name__=="__main__":
app.run()
HTML:
Hyper text marcup language. It is used to create static web pages .
Invented by Tim Berners Lee & he is the one who invented internet in 1991.
Hyper Text refers to linkinf of web pages together
Marcup language refers to a document which tells you how to structurize the
display
Specifications of HTML:
-> HTML 1.O
-> HTML 2.O
-> HTML 3.2
-> HTML 4
-> HTML 5 (LATEST VERSION OF HTML)
Advantages of HTML:
1.open source
2.easy to understand
3.user friendly
4.debugging is easy
5.flexibility
HTML Structure: :
<html>
<head>
<title> TITLE</title>
</head>
<body>
_____________________
__________________________
</body>
</html>
HTML Tag:
Any word which is enclosed within a angular brackets is referred to html tag
HTML Element:
HTML Element and HTML Tag are often same but strictly speaking HTML Element
should have start tag , content , closed tag
Ex : <h1> Welcome </h1>
First HTML Program:
<html>
<head>
<title> TITLE</title>
</head>
<body>
<h1> Welcome </h1>
</body>
</html>
Basic HTML Tags:
1. Text Formatting tags
a. headings : denoted by <h1>........<h6>
h1 - big size
h2 - small size
Ex: <h2> hello </h2>
b. paragraph tag : denoted by <p>
<p> hjbsJBcjbhoHOUHI
DSKBJHWUHFEH
</p>
c. Pre formatted tag : denoted by <pre>
<pre> hjbsJBcjbhoHOUHI
DSKBJHWUHFEH</pre>
d. break tag : denoted by <br>
<p> hjbsJBcjbhoHOUHI. <br>
DSKBJHWUHFEH
</p>
e. bold/strong tag : denoted by <b> or <strong>
<b> hjbsJBcjbhoHOUHI <br>
DSKBJHWUHFEH
</b>
f. italic tag : denoted by <i>
<i> hjbsJBcjbhoHOUHI<br>
DSKBJHWUHFEH
</i>
g. underlined tag : denoted by <u>
<u> hjbsJBcjbhoHOUHI<br>
DSKBJHWUHFEH
</u>
h. Big tag : denoted by <big>
<big> hjbsJBcjbhoHOUHI <br>
DSKBJHWUHFEH
</big>
i. Small tag : denoted by <small>
<small> hjbsJBcjbhoHOUHI <br>
DSKBJHWUHFEH
</small>
j. strike tag : denoted by <strike>
<strike> hjbsJBcjbhoHOUHI <br>
DSKBJHWUHFEH
</strike>
k. delete tag : denoted by <del>
<del> hjbsJBcjbhoHOUHI <br>
DSKBJHWUHFEH
</del>
l. Mark tag : denoted by <mark>
<mark> hjbsJBcjbhoHOUHI <br>
DSKBJHWUHFEH
</mark>
m. Superscript tag : denoted by sup
<h1> hjbsJBcjbhoHOUHI <sup>DSKBJHWUHFEH</sup> </h1>
n. Subscript tag : denoted by <sub>
<h1> hjbsJBcjbhoHOUHI <sub>DSKBJHWUHFEH</sub> </h1>
o. Horizontal Ruler : denoted by <hr>
<h1> hjbsJBcjbhoHOUHI <supDSKBJHWUHFEH</sup> </h1>
<hr>
p. marquee tag : denoted by <marquee>
<marquee> hjbsJBcjbhoHOUHI <sub>DSKBJHWUHFEH</sub> </marquee>
Note : Attributes are used to display the properties of the tag
Attributes will have a name and value
Syntax :
<tag attrname=attrval>
2. Anchor Tag : denoted by <a>
3. Image Tag : denoted by <img>
<img src ="imagepath">
4. Audio Tag : denoted by <audio>
<audio controls>
<source src = "audiopath.mp3">
</audio>
5. Video Tag
<video controls>
<source src = "videopath.mp3">
</video>
6. List Tag : Collection of items
Types of List tags :
1. unordered lists
2.ordered lists
3.descriptive lists/definition lists
List tag is denoted by <li>
Unordered list is denoted by <ul>
ordered list is denoted by <ol>
Descriptive list is denoted by <dl>
1. Unordered list:
<ul type="circle">
<li> CSE </li>
<li> ECE >/li>
<li> MECH </li>
<li> EEE </li>
</ul>
2. ordered list:
<ol type="circle">
<li> CSE </li>
<li> ECE >/li>
<li> MECH </li>
<li> EEE </li>
</ol>
3. Descriptive lists/Definition lists:
<dl>
<dt>cse</dt>
<dd>faculty</dd>
<dd>students</dd>
</dl>
7. Table tag : denoted by <table>
(index3)
8. Forms : denoted by <form>
used to collect the data
Data can be collected using form elements
The different form elements are :
1. input
a. text
<from>
First Name : <input type="text" name="fn"><br>
Last Name : <input type="text" name="ln"><br>
Password : <input type="password" name="pwd"><br>
Mobile Number : <input type="number" name="mb"><br>
Date of Birth : <input type="date" name="dob"><br>
</form>
b.radio
Gender : <input type="radio" name="r"value="male">Male
<input type="radio" name="r"value="female">Female<br>
c.button
<input type="button" value="Register">
<input type="reset" value="clear">
<input type="submit" value="Click">
d. checkbox
Fav Course:
<input type="checkbox" name="cb"value="daa">DAA
<input type="checkbox" name="cb"value="os">OS
<input type="checkbox" name="cb"value="cns">CNS
<input type="checkbox" name="cb"value="atfl">ATFL
<input type="checkbox" name="cb"value="pfsd">PFSD<br>
2. selection
Branch:
<select>
<option>NONE</option>
<option>cse</option>
<option>ece</option>
<option>eee</option>
<option>bba</option>
</select><br>
3. textarea
Address:<br>
<textarea>
</textarea><br>
<br>
Note : Form attributes
Attribute to a form tag is refer to form attributes
The form attributes are:
1. action
<from action="hi.html">
<b>Student Data<b><br>
<br>
First Name : <input type="text" name="fn"><br>
Last Name : <input type="text" name="ln"><br>
<input type="submit" value="Click">
</form>
2.method
<form action="hi.html" method="GET">
<b>Student Data<b><br>
<br>
First Name : <input type="text" name="fn"><br>
Last Name : <input type="text" name="ln"><br>
<input type="submit" value="Click">
</form>
Assignment :
Cascading style sheet(CSS) :
1.Inline CSS
2.Internal CSS
3.External CSS (any 1 way)
Saturday, 25 February, 2023
Tuesday, 28 February, 2023
Redirect :
#redirect
@app.route("/route/template2/<role>")
def sample4(role):
if role=="guest":
return redirect(url_for('sample2'))
else:
return redirect(url_for('sample3',name=role))
List rendering :
#List rendering using for tag / for loop
@app.route("/List/rendering")
def sample5():
lst=["abc","kjl","lll"]
return render_template('index3.html',lst=lst)
Template Inheritence :
#Template Inheritence
@app.route("/greetings/abc")
def sample6():
lst=["kl","klo","kli"]
return render_template('home.html',lst=lst)
Form example:
#Form example
@app.route("/form/studentform")
def sample8():
return render_template('studentform.html')
MONGODB
Introduction to NOSQL:
• Nosql stands for Not Only Structure Query Language
• Nosql databases are non-relational databases whereas sql databases are
relational databases
Note : Relational database : It is a kind of database that stores and provides data
related to each other
The system which maintains relational database is refered to be RDBMS
SQL -> Relational -> tables
NONSQL -> Non-relational -> no tables
• NOSQL is specially designed for large set of data (Big Data)
Big Data : It can be defined using 3 characterstics
1. velocity (speed at which data arrives to a database)
2.volume (size of the data)
3.varirties (comments , images , videos etc)
All these 3 together defines Big data
In general, data will be in the form of
• structured data
• unstructured data
• semi structured data
• unpredictable data
Some of the popular NOSQL databases are
1. MongoDB
2. DynamoDB / AmazonDB
3. CouchDB
4. Cassendra
5. Neo4j
6. Riak etc
Differences between SQL & NOSQL
SQL
1. Data stored in tables
2. Structured data
3. Sql is used for relatively smaller data
4.Scalability is limited
NOSQL
1. Data is not stored in tables
2. unstructured data
3. Nosql is used for larger data
4. Scalability is unlimited
studentdetails.insert_one(a )
studentdetails.insert_many(b)
return "Document Successfully Inserted"
if__name__=="__main__":
app.run( )
In templates :
studentform.html
<body>
<form action ="{{url_for('onsubmit')}}>
First Name:<input type="text" name="fn"><br>
Last Name:<input type="text" name="ln"><br>
Register Number : <input type ="number" name="regno"><br>
Mobile Number :<input type="number" name="mb"><br>
<br>
<input type="submit" value="click here">
</form>
</body>
#retrieve document
b=studentdetails.find( )
return render_template('retrieve.html',b=b)
retrieve.html
<body>
{% for x in b%}
{{x}}
{ % endfor %}
</body>
#delete document
studentdetails.remove( { } )
return "document deleted successfully"
MongoDB Compass :
Create and insert and update and delete the data and retrieve
MongoDB Atlas : (Cloud)
client = MongoClient("mongodb://127.0.0.1:27017")
MongoDB Atlas -
mongodb+srv://srilu:<password>@cluster0.u86vi4s.mongodb.net/?
retryWrites=true&w=majority
client =
MongoClient("mongodb+srv://srilu:<password>@cluster0.u86vi4s.mongodb.net/
?retryWrites=true&w=majority")
Django Framework
--> What is web Application
--> Components of web Application
--> Introduction to django framework
--> How to create a django project
--> How to create an application
--> Project structure and app structure
--> How to run an application
--> views and http response
--> Dynamic routing
--> Template rendering
--> Context Passing to Template
--> Redirect
--> Template Inheritence
--> Static content
--> CRUD Operations
--> Session management
--> Builtin user model, checking authentication and admin panel configuration
--> writing models
--> working on complete django project from scratch
--> Hosting
* Web Application :
FE , BE , Connectivity
Local Application Global Application
Runs on a client Runs on a web server
Components of web application :
In general , every web application framework architecture follows MVC
Architecture
M - model (BE)
V -view (FE)
C -controller (Connectivity)
- whereas django framework follows MVT Architecture
M - model (BE)
V - view (FE)
T - Template (Django provides a lot of pre-defined templates to a user or
developer
pages/urls.py
from django.urls import path,include
from .views import sample1
urlpatterns = [
path('',sample1,name='NR')
]
* Dynamic routing
context passing
def sample5(request, name):
return render(request, "index.html", {'name':name})
def sample6(request):
lst=['fknf','jfkej','efihze']
return render(request, "index1,html" , {'names':lst})
urls.py
path('template1/',sample3,name='TR')
path('template2/<name>/',sample4,name='CTR')
path('template3/',sample5,name='CTR1')
path('listrender/',sample6,name='LR')
Template inheritence :
def sample8(request):
return render(request,"Inheritence.html")
urls.py
path('template4/',sample8,name='TI')
checking authentication :
from django.contrib.auth import authenticate
models.py
class Student(models.Model):
firstname = models.CharField(max_length=40)
lastname = models.CharField(max_length=40)
class Vehicle(models.Model):
regno = models.CharField(max_length=20)
model= models.DateField()
name= models.CharField(max_length=40)
yearofmanf = models.IntegerField()
Note :
The firstname and lastname of student model are called as fields. each field is
specified as class attribute and each attribute maps to a database column
https://docs.djangoproject.com/en/4.1/topics/db/models/