Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IISc-Bengaluru
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
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
2024 Competition
IISc-Bengaluru
Commits
d02f19bc
Commit
d02f19bc
authored
7 months ago
by
Krishna Agarwal
Browse files
Options
Downloads
Patches
Plain Diff
Replace app.py
parent
25f33ecd
No related branches found
No related tags found
2 merge requests
!2
Blog Ready
,
!1
Krishna
Pipeline
#413532
failed
7 months ago
Stage: build
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app.py
+52
-35
52 additions, 35 deletions
app.py
with
52 additions
and
35 deletions
app.py
+
52
−
35
View file @
d02f19bc
from
os
import
path
from
pathlib
import
Path
from
flask
import
Flask
,
render_template
from
flask_frozen
import
Freezer
template_folder
=
path
.
abspath
(
'
./wiki
'
)
app
=
Flask
(
__name__
,
template_folder
=
template_folder
)
#app.config['FREEZER_BASE_URL'] = environ.get('CI_PAGES_URL')
app
.
config
[
'
FREEZER_DESTINATION
'
]
=
'
public
'
app
.
config
[
'
FREEZER_RELATIVE_URLS
'
]
=
True
app
.
config
[
'
FREEZER_IGNORE_MIMETYPE_WARNINGS
'
]
=
True
freezer
=
Freezer
(
app
)
@app.cli.command
()
def
freeze
():
freezer
.
freeze
()
@app.cli.command
()
def
serve
():
freezer
.
run
()
@app.route
(
'
/
'
)
def
home
():
return
render_template
(
'
pages/home.html
'
)
@app.route
(
'
/<page>
'
)
def
pages
(
page
):
return
render_template
(
str
(
Path
(
'
pages
'
))
+
'
/
'
+
page
.
lower
()
+
'
.html
'
)
# Main Function, Runs at http://0.0.0.0:8080
if
__name__
==
"
__main__
"
:
app
.
run
(
port
=
8080
)
from
os
import
path
,
walk
,
getcwd
from
pathlib
import
Path
import
markdown2
from
flask
import
Flask
,
render_template
from
flask_frozen
import
Freezer
template_folder
=
path
.
abspath
(
'
./wiki
'
)
app
=
Flask
(
__name__
,
template_folder
=
template_folder
)
#app.config['FREEZER_BASE_URL'] = environ.get('CI_PAGES_URL')
app
.
config
[
'
FREEZER_DESTINATION
'
]
=
'
public
'
app
.
config
[
'
FREEZER_RELATIVE_URLS
'
]
=
True
app
.
config
[
'
FREEZER_IGNORE_MIMETYPE_WARNINGS
'
]
=
True
freezer
=
Freezer
(
app
)
@app.cli.command
()
def
freeze
():
freezer
.
freeze
()
@app.cli.command
()
def
serve
():
freezer
.
run
()
@app.route
(
'
/
'
)
def
home
():
return
render_template
(
'
pages/home.html
'
)
def
markdown_html
():
filenames
=
next
(
walk
(
'
./wiki/markdowns/
'
),
(
None
,
None
,
[]))[
2
]
print
(
filenames
)
bloglist
=
{}
for
filename
in
filenames
:
with
open
(
f
'
./wiki/markdowns/
{
filename
}
'
,
'
r
'
)
as
file
:
bloglist
[
filename
]
=
markdown2
.
markdown
(
file
.
read
(),
extras
=
[
"
metadata
"
])
print
(
bloglist
)
return
bloglist
@app.route
(
'
/blog
'
)
def
blogs
():
x
=
markdown_html
()
print
(
x
[
'
template.md
'
].
metadata
)
return
render_template
(
'
pages/blog.html
'
,
bloglist
=
markdown_html
())
@app.route
(
'
/<page>
'
)
def
pages
(
page
):
return
render_template
(
str
(
Path
(
'
pages
'
))
+
'
/
'
+
page
.
lower
()
+
'
.html
'
)
# Main Function, Runs at http://0.0.0.0:8080
if
__name__
==
"
__main__
"
:
app
.
run
(
port
=
8080
)
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