Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
url_shorter_docker
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
Service Desk
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
Jonas Leder
url_shorter_docker
Commits
9360cd17
Commit
9360cd17
authored
5 years ago
by
Jonas Leder
Browse files
Options
Downloads
Patches
Plain Diff
edid some coments
parent
78aa1cdc
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+6
-6
6 additions, 6 deletions
main.py
with
6 additions
and
6 deletions
main.py
+
6
−
6
View file @
9360cd17
...
...
@@ -23,10 +23,10 @@ try:
if
(
os
.
environ
[
"
show_build_date
"
]
==
"
1
"
):
#If you want to see the builddate you can enable this enviorement variable
builddate
=
"
, Build date:
"
+
open
(
"
builddate.txt
"
,
"
r
"
).
read
()
except
:
pass
#This
normaly only happens, if the script runs without a container for
testing
.
pass
#This
exception is only to pass it while
testing
try
:
if
(
os
.
environ
[
"
production
"
]
==
"
1
"
):
#If you
disable production the flask testserver will be used, because it makes more debug output
if
(
os
.
environ
[
"
production
"
]
==
"
1
"
):
#If you
use this in production, please set this to 1, because the Flask Testserver is not very secure
production
=
True
else
:
production
=
False
...
...
@@ -57,16 +57,16 @@ def table_check():
def
makeQR
(
text
):
#This function is used to create a QR code and encode it base64, if you make a new shortlink
qr
=
qrcode
.
QRCode
(
qr
=
qrcode
.
QRCode
(
#QR generation variables
version
=
1
,
error_correction
=
qrcode
.
constants
.
ERROR_CORRECT_L
,
box_size
=
10
,
border
=
1
,
)
qr
.
add_data
(
text
)
qr
.
make
(
fit
=
True
)
qr
.
add_data
(
text
)
#The URL is in the text variable
qr
.
make
(
fit
=
True
)
#Generate the QR
img
=
qr
.
make_image
(
fill_color
=
"
black
"
,
back_color
=
"
white
"
)
img
=
qr
.
make_image
(
fill_color
=
"
black
"
,
back_color
=
"
white
"
)
#Encode the WR as base 64
with
BytesIO
()
as
buffer
:
img
.
save
(
buffer
,
'
jpeg
'
)
return
base64
.
b64encode
(
buffer
.
getvalue
()).
decode
()
...
...
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