diff --git a/codegen.py b/codegen.py index 2375a6d..f15bc50 100644 --- a/codegen.py +++ b/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(): """ + elif qrtype == "VCARD": + form = f""" +

Configure

+ """ else: form = f"""

Enter Telephone:

@@ -68,7 +73,6 @@ def index():

- """ @@ -89,6 +93,26 @@ def index(): codeimg = f'' elif qrtype == "WIFI": codeimg = f'' + 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'' except: print("nocontent") codeimg = "

fill out info to generate qr code

" @@ -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': diff --git a/readme.md b/readme.md index 5a53ef3..2c5b444 100644 --- a/readme.md +++ b/readme.md @@ -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 diff --git a/templates/Vcardconf.html b/templates/Vcardconf.html new file mode 100644 index 0000000..559b902 --- /dev/null +++ b/templates/Vcardconf.html @@ -0,0 +1,73 @@ + + + + + Here To There + + + + +
+ + +

Contact QR Config

+ + + + + + + + + + + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html index dab1fdb..8d6a35b 100644 --- a/templates/home.html +++ b/templates/home.html @@ -83,6 +83,7 @@

Telephone

Email

Wifi

+

Contact

+

Personal Info

+

First Name:

+ +

Last Name

+ +

Gender

+ +
+

Email

+

Main:

+ +
+

Phone

+

cell:

+ +

Home:

+ + +
+