forked from sushriyamogasala/flask-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
42 lines (32 loc) · 1.03 KB
/
server.py
File metadata and controls
42 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from cProfile import run
from unicodedata import name
from flask import Flask , redirect , url_for , request
app = Flask(__name__)
@app.route('/admin')
def admin():
return "occhev entra admin uu"
@app.route('/guest/<guestname>')
def guest(guestname):
if guestname!="admin":
return "kottha ga occhav entra %s"% guestname
return redirect(url_for('admin'))
@app.route('/user/<name>')
def check(name):
if name == 'admin':
return redirect (url_for('admin'))
else:
return redirect(url_for('guest',guestname=name))
@app.route('/welcome/<welcomename>')
def welcome(welcomename):
return "welcome ra %s" % welcomename
@app.route('/login',methods=['POST','GET'])
def login():
if request.method == 'POST':
user = request.form['uname']
return redirect(url_for('welcome',welcomename=user))
else:
user = request.args.get('uname')
return redirect(url_for('welcome',welcomename=user))
if __name__=="__main__":
app.debug=True
app.run(port=5000)