Skip to content

Commit cd5524a

Browse files
committed
initial
1 parent d1afc0b commit cd5524a

File tree

11 files changed

+127
-0
lines changed

11 files changed

+127
-0
lines changed

Python Flask/app.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask import Flask
2+
app=Flask(__name__)
3+
@app.route('/')
4+
def hello_world():
5+
return 'rvce.edu.in'
6+
if __name__ == '__main__':
7+
app.run(debug=True)

Python Flask/app10.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from flask import Flask, render_template
2+
app = Flask(__name__)
3+
4+
@app.route('/result')
5+
def result():
6+
dict = {'phy':50,'che':60,'maths':70}
7+
return render_template('result.html', result = dict)
8+
9+
if __name__ == '__main__':
10+
app.run(debug = True)

Python Flask/app2.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from flask import Flask, redirect, url_for
2+
3+
app = Flask(__name__)
4+
5+
@app.route('/admin')
6+
7+
def hello_admin():
8+
return 'Hello Admin'
9+
10+
@app.route('/guest/<guest>')
11+
12+
def hello_guest(guest):
13+
return 'Hello %s as Guest' % guest
14+
15+
@app.route('/user/<name>')
16+
17+
def hello_user(name):
18+
if name =='admin':
19+
return redirect(url_for('hello_admin'))
20+
else:
21+
return redirect(url_for('hello_guest',guest = name))
22+
23+
if __name__ == '__main__':
24+
app.run(debug = True)

Python Flask/app3.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from flask import Flask, redirect, url_for, request
2+
app = Flask(__name__)
3+
4+
@app.route('/success/<name>')
5+
def success(name):
6+
return 'welcome %s' % name
7+
8+
@app.route('/login',methods = ['POST', 'GET'])
9+
def login():
10+
if request.method == 'POST':
11+
user = request.form['nm']
12+
return redirect(url_for('success',name = user))
13+
else:
14+
user = request.args.get('nm')
15+
return redirect(url_for('success',name = user))
16+
#return render_template('login.html',form=form)
17+
18+
if __name__ == '__main__':
19+
app.run(debug = True)

Python Flask/app7.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from flask import Flask, render_template
2+
app = Flask(__name__)
3+
4+
@app.route('/')
5+
def index():
6+
return render_template('hello.html')
7+
8+
if __name__ == '__main__':
9+
app.run(debug = True)

Python Flask/app8.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from flask import Flask, render_template
2+
app = Flask(__name__)
3+
4+
@app.route('/hello/<user>')
5+
def hello_name(user):
6+
return render_template('hello.html', name = user)
7+
8+
if __name__ == '__main__':
9+
app.run(debug = True)

Python Flask/app9.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from flask import Flask, render_template
2+
app = Flask(__name__)
3+
4+
@app.route('/hello1/<int:score>')
5+
def hello_name(score):
6+
return render_template('hello1.html', marks = score)
7+
8+
if __name__ == '__main__':
9+
app.run(debug = True)

Python Flask/templates/hello.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!doctype html>
2+
<html>
3+
<body>
4+
5+
<h1>Hello {{ name }}!</h1>
6+
7+
</body>
8+
</html>

Python Flask/templates/hello1.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!doctype html>
2+
<html>
3+
<body>
4+
{% if marks>50 %}
5+
<h1> Your result is pass!</h1>
6+
{% else %}
7+
<h1>Your result is fail</h1>
8+
{% endif %}
9+
</body>
10+
</html>

Python Flask/templates/login.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html>
2+
<body>
3+
<form action = "http://localhost:5000/login" method = "post">
4+
<p>Enter Name:</p>
5+
<p><input type = "text" name = "nm" /></p>
6+
<p><input type = "submit" value = "submit" /></p>
7+
</form>
8+
</body>
9+
</html>

0 commit comments

Comments
 (0)