Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Rashid_Ashfaq/Flaskfundamentals/Counter/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from flask import Flask ,render_template, request ,redirect,session
app = Flask(__name__)
app.secret_key="ThisisSecret"

@app.route('/')
def index():
if session.get('counter') == None:
session['counter'] =2

return render_template('index.html')

@app.route('/addcount',methods=['POST'])
def addcounter():
session['counter'] +=2
return redirect('/')

@app.route('/resetcount',methods=['POST'])
def reset():
session['counter'] = 1
return redirect('/')

app.run(debug=True)

26 changes: 26 additions & 0 deletions Rashid_Ashfaq/Flaskfundamentals/Counter/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Counter</title>
<style>

h1{
color: green;
margin-top: 200px;
}

</style>
</head>
<body>
<h1>Counter</h1>
{{session['counter']}}
<div>
<form action="/addcount" method="post" >
<button>ADD 2</button>
</form>
<form action="/resetcount" method="post">
<button>Reset</button>
</form>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions Rashid_Ashfaq/Flaskfundamentals/DisappearingNinja/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from flask import Flask ,render_template
app =Flask(__name__)
@app.route('/')
def index():
return render_template("index.html",display ="NO NINJA HERE")
@app.route('/ninja')
def ninja():
return render_template('ninja.html')

@app.route('/ninja/blue')
def ninjablue():
return render_template('blue.html')

@app.route('/ninja/orange')
def ninjaorange():
return render_template('orange.html')

@app.route('/ninja/red')
def ninjared():
return render_template('red.html')

@app.route('/ninja/purple')
def ninjpurple():
return render_template('purple.html')
@app.route('/ninja/<username>')
def notapril(username):
return render_template("notapril.html", username=username)

app.run(debug=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h1{
color: blue;
text-align: center;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Blue Ninja</title>
<img src="{{url_for('static',filename='img/leonardo.jpg')}}">
</head>
<body>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Disappearing Ninja</title>
<link rel="stylesheet" type="text/css" href="{{url_for('static',filename='css/style.css')}}">
<style>
h1{
color: blue;
text-align: center;

}
</style>
</head>
<body>
<h1> {{display}} </h1>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>display all four Ninja</title>
</head>
<body>
<img src="{{url_for('static',filename= 'img/tmnt.png')}}">
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>NOtAPRIL</title>
<img src="{{url_for('static',filename='img/notapril.jpg')}}">
</head>
<body>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Orange Ninja</title>
<img src="{{url_for('static',filename='img/michelangelo.jpg')}}">
</head>
<body>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Purple Ninja</title>
<img src="{{url_for('static',filename='img/donatello.jpg')}}">
</head>
<body>

</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Red Ninja</title>
<img src="{{url_for('static',filename='img/raphael.jpg')}}">
</head>
<body>

</body>
</html>
31 changes: 31 additions & 0 deletions Rashid_Ashfaq/Flaskfundamentals/DojoSurvey/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from flask import Flask, render_template ,request ,redirect,session, flash
app = Flask(__name__)
app.secret_key ="KeepItSecretKeepItSafe"
@app.route('/')
def index():
return render_template('index.html')

@app.route('/result', methods=['POST'])
def result():
name =request.form['name']
if len(request.form['name'])<1:
flash("Name cannot be empty")
return redirect('/')
location =request.form['location']
language=request.form["language"]
comment=request.form['comment']
if len(request.form['comment'])<1:
flash("Comment can not be empty")
return redirect('/')
if len(comment)>120:
flash("Comment no more then 120 character ")
return redirect('/')

return render_template('result.html',name= name,location=location,language=language,comment=comment)
return render_template('index.html')
@app.route('/back')
def back():
return render_template('index.html')

app.run(debug=True)

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.dojoform ul{
width: 750px;
list-style-type: none;
list-style-position: outside;
margin: 0px;
padding: 0px;
}
81 changes: 81 additions & 0 deletions Rashid_Ashfaq/Flaskfundamentals/DojoSurvey/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<!DOCTYPE html>
<html>
<head>
<title>Dojo Survey Index</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css"><!-- CSS is not woring-->
<style>
.dojoform ul{
width: 750px;
list-style-type: none;
list-style-position: outside;
margin: 0px;
padding: 0px;
}
.dojoform li{
padding: 20px;
position: relative;
}
.dojoform label{
width: 150px;
margin-top: 3px;
display: inline-block;
float:left;
padding: 3px;
}
.dojoform input{
height: 20px;
width: 220px;
padding: 5px,8px;
}
button{
background-color: #76A5AF;
color: white;
margin-left: 294px;
padding: 4px;
margin-top: -9px;
}

</style>

</head>
<body>
{% with messages = get_flashed_messages() %}
{%if messages%}
{% for message in messages%}
<p>{{message}}</p>
{% endfor%}
{%endif%}
{%endwith%}
<form class ="dojoform" action="/result", method="post">
<ul>
<li>
<label for ="name">Your Name</label>
<input type="text" name="name" placeholder="enter name here" />
</li>
<li>
<label for ="location">Dojo Location</label>
<select name ="location">
<option value="select">--Select--</option>
<option value="san jose">San Jose</option>
<option value="dallas">Dallas</option>
<option value="tulsa">TULSA</option>
<option value="chicago">CHICAGO</option>
</select>
</li>
<li>
<label for ="language">Favorite Language</label>
<select name =language>
<option value="select">--Select--</option>
<option value="python">Python</option>
<option value="javscript">Javascript</option>
</select>
</li>
<li>
<label for ="comment">Comment (Optional)</label>
<textarea value ="comment" name="comment"></textarea>
</li>
</ul>
<button>Button</button>
</form>
</body>
</html>
70 changes: 70 additions & 0 deletions Rashid_Ashfaq/Flaskfundamentals/DojoSurvey/templates/result.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html>
<head>
<title>Dojo Survey Index</title>
<style>
table{
border: 2px solid black;
width: auto;
margin: 200px;
padding-bottom: 30px;
text-align: left;
}

h2{
text-decoration: underline;
text-align: left;
}
button{
margin-top: 19px;
margin-left: 204px;
padding: 6px;
padding-left: 15px;
padding-right: 15px;
background-color: #76A5AF;
color: white;
border: 1px solid black;
}
th{
width: 203px;
display: inline-block;
}
td{

display: inline;
}
</style>
</head>
<body>
{% with messages = get_flashed_messages() %}
{%if messages%}
{% for message in messages%}
<p>{{message}}</p>
{% endfor%}
{%endif%}
{%endwith%}

<form action="/back" method="Get">
<table >
<tr>
<th><h2>Submitedt Info</h2></th>
</tr>
<tr>
<th>Name:</th><td>{{name}}</td>
</tr>
<tr>
<th>Location:</th><td>{{location}}</td>
</tr>
<tr>
<th>Language:</th><td> {{language}}</td>
</tr>
<tr>
<th>Comment:</th><td>{{comment}}</td>
</tr>
<tr>
<td>
<button>Back</button>
</td>
</tr>
</body>
</html>
Loading