-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from debemdeboas/DeB-1
Various changes
- Loading branch information
Showing
4 changed files
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
import hashlib | ||
import segno | ||
|
||
from datetime import datetime | ||
|
||
IMG_OUTPUT_PATH = 'static/qrcodes/' | ||
|
||
|
||
def generate_qrcode_image(content, err_lvl): | ||
return segno.make(content, error = err_lvl) | ||
return segno.make(content, error=err_lvl) | ||
|
||
|
||
def create_qrcode(content, error='H'): | ||
filename = IMG_OUTPUT_PATH \ | ||
+ hashlib.sha256( | ||
f'{content}_{datetime.now()}'.encode('utf-8')).hexdigest() \ | ||
+ '.svg' | ||
|
||
def create_qrcode(content, error = 'H'): | ||
filename = IMG_OUTPUT_PATH + hashlib.sha256(f'{content}_{datetime.now()}'.encode('utf-8')).hexdigest() + '.svg' | ||
generate_qrcode_image(content, error).save(filename, scale=10, light='white', dark='black') | ||
generate_qrcode_image(content, error).save( | ||
filename, | ||
scale=10, | ||
light='white', | ||
dark='black') | ||
return filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="container"> | ||
<div class="container text-center"> | ||
<div class="container" style="padding: 7px;"> | ||
<img src="{{ img }}" alt="QRCode for '{{ content }}'" width="100%"> | ||
</div> | ||
<a class="btn btn-primary" href="{{ url_for('homepage') }}" role="button">Generate another!</a> | ||
|
||
<div class="container"> | ||
<a class="btn btn-primary" href="{{ url_for('homepage') }}" role="button">Generate another</a> | ||
<a class="btn btn-primary" href="{{ img }}" role="button" download="QRCode.svg"><i class="fa fa-download"></i> Download</a> | ||
</div> | ||
</div> | ||
{% endblock %} |