commit
bcaed4bd5c
32
codegen.py
32
codegen.py
@ -2,6 +2,7 @@ import qrcode
|
||||
import os
|
||||
from io import BytesIO
|
||||
from flask import Flask, send_file, request, render_template_string, render_template
|
||||
from urllib.parse import quote
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@ -60,6 +61,10 @@ def index():
|
||||
<p id="error" style="color: red; display: none;">File size must be below !MAXFILESIZEHERE! MB.</p>
|
||||
</form>
|
||||
"""
|
||||
elif qrtype == "VCARD":
|
||||
form = f"""
|
||||
<a href="Vcard"> <h1> Configure </h1> </a>
|
||||
"""
|
||||
else:
|
||||
form = f"""
|
||||
<h2>Enter Telephone:</h2>
|
||||
@ -68,7 +73,6 @@ def index():
|
||||
<input type="text" name="link" id="link" />
|
||||
<br><br>
|
||||
<input type="submit" value="Upload" id="submitButton" />
|
||||
<p id="error" style="color: red; display: none;">File size must be below !MAXFILESIZEHERE! MB.</p>
|
||||
</form>
|
||||
"""
|
||||
|
||||
@ -89,6 +93,26 @@ def index():
|
||||
codeimg = f'<img src="qrcode?link=TEL:{request.args.get('link')}" width="400" height="400">'
|
||||
elif qrtype == "WIFI":
|
||||
codeimg = f'<img src="qrcode?link=WIFI:S:{request.args.get('NAME')};T:{request.args.get('security')};P:{request.args.get('password')};;" width="400" height="400">'
|
||||
elif qrtype == "VCARD":
|
||||
codeimg = ""
|
||||
if request.args.get('FNAME') and request.args.get('LNAME'):
|
||||
codeimg += f"FN:{request.args.get('FNAME')} {request.args.get('LNAME')} \nN;CHARSET=UTF-8:{request.args.get('LNAME')};{request.args.get('FNAME')};;;\n"
|
||||
if request.args.get('Gender'):
|
||||
codeimg += f"GENDER:{request.args.get('Gender')}\n"
|
||||
if request.args.get('MEMAIL'):
|
||||
codeimg += f"EMAIL:{request.args.get('MEMAIL')}\n"
|
||||
if request.args.get('CELLPHONE'):
|
||||
codeimg += f"TEL;TYPE=CELL:{request.args.get('CELLPHONE')}\n"
|
||||
if request.args.get('HOMEPHONE'):
|
||||
codeimg += f"TEL;TYPE=HOME,VOICE:{request.args.get('HOMEPHONE')}\n"
|
||||
codeimg = f"""
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
{codeimg}END:VCARD
|
||||
"""
|
||||
encoded_vcard = quote(codeimg)
|
||||
print(codeimg)
|
||||
codeimg = f'<img src="qrcode?link={codeimg}" width="400" height="400">'
|
||||
except:
|
||||
print("nocontent")
|
||||
codeimg = "<h2> fill out info to generate qr code </h2>"
|
||||
@ -97,7 +121,11 @@ def index():
|
||||
print(codeimg)
|
||||
return render_template("home.html", form=form, codeimg=codeimg)
|
||||
|
||||
|
||||
@app.route('/Vcard', methods=['GET', 'POST'])
|
||||
def vcard():
|
||||
return render_template("Vcardconf.html")
|
||||
|
||||
|
||||
@app.route('/qrcode', methods=['GET', 'POST'])
|
||||
def generate_qrcode():
|
||||
if request.method == 'POST':
|
||||
|
@ -1,4 +1,5 @@
|
||||
# self hosted qr code generator
|
||||
# easy self hosted qr code generator
|
||||
### Because every other one wants to steal your data
|
||||
just run compose file, port is 7123
|
||||
|
||||
## current functionality
|
||||
|
73
templates/Vcardconf.html
Normal file
73
templates/Vcardconf.html
Normal file
@ -0,0 +1,73 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Here To There</title>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Montserrat', sans-serif;
|
||||
background: linear-gradient(90deg, hsla(198, 100%, 50%, 1) 0%, hsla(188, 92%, 49%, 1) 48%, hsla(201, 100%, 49%, 1) 97%);
|
||||
text-align: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
td {
|
||||
padding: 20px;
|
||||
width: 20px;
|
||||
background-color: white;
|
||||
border-radius: 20px;
|
||||
}
|
||||
h1 {
|
||||
background-color: gray;
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
color: white;
|
||||
background-color: black;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form action="." method="get" enctype="multipart/form-data" id="uploadForm" style="width: 75%;">
|
||||
<input type="hidden" name="type" value="VCARD">
|
||||
<input type="hidden" name="link" value="VCARD">
|
||||
<h1> Contact QR Config </h1>
|
||||
<table style="width: 100%;">
|
||||
<tr>
|
||||
<td>
|
||||
<h1>Personal Info</h1>
|
||||
<h3>First Name:</h3>
|
||||
<input type="text" name="FNAME" id="FNAME" />
|
||||
<h3>Last Name</h3>
|
||||
<input type="text" name="LNAME" id="LNAME" />
|
||||
<h3>Gender</h3>
|
||||
<select name="Gender" id="Gender">
|
||||
<option value="M">Male</option>
|
||||
<option value="F">Female</option>
|
||||
<option value="O">Other</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<h1>Email</h1>
|
||||
<h3>Main:</h3>
|
||||
<input type="text" name="MEMAIL" id="MEMAIL" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h1>Phone</h1>
|
||||
<h3>cell:</h3>
|
||||
<input type="Phone" name="CELLPHONE" id="CELLPHONE" />
|
||||
<h3>Home:</h3>
|
||||
<input type="Phone" name="HOMEPHONE" id="HOMEPHONE" />
|
||||
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<input type="submit" value="Upload" id="submitButton" />
|
||||
</body>
|
@ -83,6 +83,7 @@
|
||||
<a href="?type=TEL"><h1>Telephone</h1></a>
|
||||
<a href="?type=MAIL"><h1>Email</h1></a>
|
||||
<a href="?type=WIFI"><h1>Wifi</h1></a>
|
||||
<a href="?type=VCARD"><h1>Contact</h1></a>
|
||||
</td>
|
||||
<td>
|
||||
<div class="upload">
|
||||
|
Loading…
x
Reference in New Issue
Block a user