FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
30-Days-Of-Python/python_for_web/app.py at master · htmlsocha/30-Days-Of-Python · GitHub
htmlsocha
/
30-Days-Of-Python
Public
Notifications
You must be signed in to change notification settings
Fork
1
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
30-Days-Of-Python
/
python_for_web
/
app.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (31 loc) · 1.19 KB
Breadcrumbs
30-Days-Of-Python
/
python_for_web
/
app.py
Copy path
File metadata and controls
39 lines (31 loc) · 1.19 KB
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
34
35
36
37
38
39
# let's import the flask
from
flask
import
Flask
,
render_template
,
request
,
redirect
,
url_for
import
os
# importing operating system module
app
=
Flask
(
__name__
)
# to stop caching static file
app
.
config
[
'SEND_FILE_MAX_AGE_DEFAULT'
]
=
0
@
app
.
route
(
'/'
)
# this decorator create the home route
def
home
():
techs
=
[
'HTML'
,
'CSS'
,
'Flask'
,
'Python'
]
name
=
'30 Days Of Python Programming'
return
render_template
(
'home.html'
,
techs
=
techs
,
name
=
name
,
title
=
'Home'
)
@
app
.
route
(
'/about'
)
def
about
():
name
=
'30 Days Of Python Programming'
return
render_template
(
'about.html'
,
name
=
name
,
title
=
'About Us'
)
@
app
.
route
(
'/result'
)
def
result
():
return
render_template
(
'result.html'
)
@
app
.
route
(
'/post'
,
methods
=
[
'GET'
,
'POST'
])
def
post
():
name
=
'Text Analyzer'
if
request
.
method
==
'GET'
:
return
render_template
(
'post.html'
,
name
=
name
,
title
=
name
)
if
request
.
method
==
'POST'
:
content
=
request
.
form
[
'content'
]
return
redirect
(
url_for
(
'result'
))
if
__name__
==
'__main__'
:
# for deployment
# to make it work for both production and development
port
=
int
(
os
.
environ
.
get
(
"PORT"
,
5000
))
app
.
run
(
debug
=
True
,
host
=
'0.0.0.0'
,
port
=
port
)
Back
|
FazBrowse Home
|
New Git URL