Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DBS 2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
jonahbeneb02
DBS 2022
Commits
ef78663e
Verified
Commit
ef78663e
authored
2 years ago
by
jonahbeneb02
Browse files
Options
Downloads
Patches
Plain Diff
Show diagram as svg
parent
c8b96717
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app.py
+4
-6
4 additions, 6 deletions
src/app.py
src/templates/publishers.html
+3
-1
3 additions, 1 deletion
src/templates/publishers.html
with
7 additions
and
7 deletions
src/app.py
+
4
−
6
View file @
ef78663e
...
...
@@ -3,7 +3,7 @@ from flask import Flask, request, send_from_directory
from
flask
import
render_template
import
psycopg2
from
matplotlib
import
pyplot
as
plt
from
io
import
Bytes
IO
from
io
import
String
IO
import
base64
database
=
conn
=
psycopg2
.
connect
(
...
...
@@ -31,13 +31,11 @@ def publishers():
rows
=
cursor
.
fetchall
()
lists
=
list
(
zip
(
*
rows
))
buffer
=
Bytes
IO
()
buffer
=
String
IO
()
fig
=
plt
.
figure
(
figsize
=
(
15
,
15
))
plt
.
pie
(
lists
[
0
],
labels
=
lists
[
1
])
fig
.
savefig
(
buffer
,
format
=
"
png
"
)
data
=
str
(
base64
.
b64encode
(
buffer
.
getvalue
()),
"
utf-8
"
)
image
=
f
"
data:image/png;base64,
{
data
}
"
return
render_template
(
"
publishers.html
"
,
title
=
"
Publishers
"
,
image
=
image
)
fig
.
savefig
(
buffer
,
format
=
"
svg
"
)
return
render_template
(
"
publishers.html
"
,
title
=
"
Publishers
"
,
image
=
buffer
.
getvalue
())
@app.route
(
"
/
"
)
...
...
This diff is collapsed.
Click to expand it.
src/templates/publishers.html
+
3
−
1
View file @
ef78663e
...
...
@@ -3,5 +3,7 @@
{% block content %}
<h1>
Publishers
</h1>
<img
width=
"100%"
src=
"{{ image }}"
>
<img
width=
"100%"
>
{{ image | safe }}
</img>
{% endblock content %}
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