FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonstudy/flask/hello.py at master · seven/pythonstudy · GitHub
seven
/
pythonstudy
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonstudy
/
flask
/
hello.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
33 lines (28 loc) · 959 Bytes
Breadcrumbs
pythonstudy
/
flask
/
hello.py
Copy path
File metadata and controls
33 lines (28 loc) · 959 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
from
flask
import
Flask
,
session
,
redirect
,
url_for
,
escape
,
request
app
=
Flask
(
__name__
)
app
.
config
[
'DEBUG'
]
=
True
@
app
.
route
(
'/'
)
def
index
():
if
'username'
in
session
:
return
'Logged in as %s'
%
escape
(
session
[
'username'
])
return
'You are not logged in'
@
app
.
route
(
'/login'
,
methods
=
[
'GET'
,
'POST'
])
def
login
():
if
request
.
method
==
'POST'
:
session
[
'username'
]
=
request
.
form
[
'username'
]
return
redirect
(
url_for
(
'index'
))
return
'''
<form action="" method="post">
<p><input type=text name=username>
<p><input type=submit value=Login>
</form>
'''
@
app
.
route
(
'/logout'
)
def
logout
():
# remove the username from the session if it's there
session
.
pop
(
'username'
,
None
)
return
redirect
(
url_for
(
'index'
))
# set the secret key. keep this really secret:
app
.
secret_key
=
'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
)
Back
|
FazBrowse Home
|
New Git URL