Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cse16259_openlab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aslesha
cse16259_openlab
Commits
8f780e5b
Commit
8f780e5b
authored
6 years ago
by
aslesha
Browse files
Options
Downloads
Patches
Plain Diff
Update flask.py
parent
cc57e8f0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lab9/flask.py
+57
-0
57 additions, 0 deletions
lab9/flask.py
with
57 additions
and
0 deletions
lab9/flask.py
+
57
−
0
View file @
8f780e5b
from
flask
import
Flask
,
redirect
,
url_for
,
render_template
app
=
Flask
(
__name__
)
@app.route
(
'
/
'
)
def
hello_world
():
return
'
Hello World!
'
@app.route
(
'
/about
'
)
def
about
():
return
'
About Page
'
@app.route
(
'
/Name/
'
)
@app.route
(
'
/Name/<name>
'
)
def
displayName
(
name
):
if
name
is
None
:
return
'
No Name
'
else
:
return
'
My Name is %s
'
%
name
@app.route
(
'
/Number/<int:reg_no>
'
)
# float can also be used
def
displayNo
(
reg_no
):
return
"
Your Regnumber is %d
"
%
reg_no
@app.route
(
'
/admin
'
)
def
hello_admin
():
return
'
Hello Admin
'
@app.route
(
'
/guest/<guest>
'
)
def
hello_guest
(
guest
):
return
'
Hello %s as Guest
'
%
guest
@app.route
(
'
/user/<name>
'
)
def
hello_user
(
name
):
if
name
==
'
admin
'
:
return
redirect
(
url_for
(
'
hello_admin
'
))
else
:
return
redirect
(
url_for
(
'
hello_guest
'
,
guest
=
name
))
@app.errorhandler
(
404
)
def
notfound
():
print
(
"
Not found Error
"
)
return
"
not found
"
@app.route
(
'
/hello/<user>
'
)
def
hello_name
(
user
):
return
render_template
(
'
hello.html
'
,
name
=
user
)
@app.route
(
'
/result
'
)
def
result
():
dict
=
{
'
phy
'
:
50
,
'
che
'
:
60
,
'
maths
'
:
70
}
return
render_template
(
'
hello.html
'
,
result
=
dict
)
@app.route
(
'
/blog
'
)
def
prac
():
user
=
{
'
username
'
:
'
AmritaCSE
'
}
posts
=
[
{
'
author
'
:
{
'
username
'
:
'
DK
'
},
'
msg
'
:
'
MS Dhoni Is A Topper In University Where I Am Still Studying
'
},
{
'
author
'
:
{
'
username
'
:
'
Rajinikanth
'
},
'
msg
'
:
'
Tamil Nadu is a secular place and we must spare no effort toensure communal harmony
'
}
]
return
render_template
(
'
blog.html
'
,
result
=
posts
,
name
=
user
)
if
__name__
==
'
__main__
'
:
app
.
run
(
debug
=
True
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment