-
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.
- Loading branch information
1 parent
48e1642
commit c06ab63
Showing
15 changed files
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn app:app |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from dotenv import main | ||
from qrcode_generator import create_qrcode | ||
from flask import Flask, request | ||
from flask_bootstrap import Bootstrap | ||
from flask.templating import render_template | ||
from dotenv import load_dotenv | ||
from forms import QRCodeForm | ||
|
||
import os | ||
|
||
load_dotenv() | ||
|
||
app = Flask(__name__) | ||
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY') | ||
bootstrap = Bootstrap(app) | ||
|
||
@app.route('/', methods=['POST', 'GET']) | ||
def homepage(): | ||
return render_template('index.html', title='QRCode Generator', form=QRCodeForm()) | ||
|
||
@app.route('/generate_qrcode', methods=['POST']) | ||
def generate_qrcode(): | ||
img_path = create_qrcode(request.form['content']) | ||
return render_template('generate_qrcode.html', title='generated QRCode', img = img_path, content = request.form['content']) | ||
|
||
if __name__ == "__main__": | ||
app.run(threaded=True, port=9691, host='0.0.0.0') |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from flask_wtf import FlaskForm | ||
from wtforms import StringField | ||
from wtforms.validators import InputRequired | ||
|
||
class QRCodeForm(FlaskForm): | ||
content = StringField( | ||
label='QRCode content', | ||
description='Link, text, email, phone number... anything!', | ||
validators=[InputRequired()], | ||
) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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) | ||
|
||
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') | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
click==7.1.2 | ||
colorama==0.4.3 | ||
dominate==2.5.2 | ||
Flask==1.1.2 | ||
Flask-Bootstrap==3.3.7.1 | ||
Flask-WTF==0.14.3 | ||
gunicorn==20.0.4 | ||
itsdangerous==1.1.0 | ||
Jinja2==2.11.2 | ||
MarkupSafe==1.1.1 | ||
Pillow==7.2.0 | ||
python-dotenv==0.14.0 | ||
qrcode-artistic==2.1.0 | ||
segno==1.3.1 | ||
six==1.15.0 | ||
visitor==0.1.3 | ||
Werkzeug==1.0.1 | ||
WTForms==2.3.3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"","short_name":"","icons":[{"src":"static/icon/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"static/icon/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends "bootstrap/base.html" %} | ||
{% import "bootstrap/wtf.html" as wtf %} | ||
|
||
{% block head %} | ||
{{ super() }} | ||
<title>{% block title %}{{ title | default('@debemdeboas') }}{% endblock %}</title> | ||
<link rel="apple-touch-icon" sizes="180x180" href="static/icon/apple-touch-icon.png"> | ||
<link rel="icon" type="image/png" sizes="32x32" href="static/icon/favicon-32x32.png"> | ||
<link rel="icon" type="image/png" sizes="16x16" href="static/icon/favicon-16x16.png"> | ||
<link rel="manifest" href="static/icon/site.webmanifest"> | ||
{% endblock %} | ||
{% block html_atrib %}lang="en"{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<div class="container"> | ||
<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> | ||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<div class="container"> | ||
<h1>welcome to the simple and effective qrcode generator (<a href="https://en.wikipedia.org/wiki/KISS_principle">KISS principle</a>)</h1> | ||
<form action="{{ url_for('generate_qrcode') }}" method="POST"> | ||
{{ wtf.form_field(form.content) }} | ||
<input class="btn btn-primary" type="submit" value="Generate!"> | ||
</form> | ||
</div> | ||
{% endblock %} |