Ejemplo n.º 1
0
def form():
    if request.method == "POST":                #If the user wants to post on this page.
        form_name = request.form["name"]
        form_phone = request.form["phone"]
        form_email = request.form["email"]
        form_fname = request.form["fname"]
        warnings.filterwarnings("ignore")
        final_data = [('N',form_name),('TEL',str("+91"+form_phone)),('EMAIL',form_email)]
        qr = QR(data=final_data,data_type='phonebook',level='h',margin_size=10,pixel_size=10)
        qr.encode()

        if not form_fname:                  #checks string is null or no    #the user may or maynot give the filename, so we do this to store it.
            form_fname = "temp"

        form_fname = form_fname+str(time.time())        #this is done to work around the caching problem of flask.

        ####os.system("mv " + qr.filename + str(" Front_end/static/QRcode/"+form_fname+".png "))   #FOR LOCAL       
        #we moved the temp qr file to static folder, we used relative addressing from the PWD.

        os.system("mv " + qr.filename + str(" /home/AdityaSingh17/flask_onweb/static/QRcode/"+form_fname+".png ")) #FOR WEB APP
        
        full_filename = os.path.join(app.config['UPLOAD_FOLDER'], (form_fname+".png"))    #under folder QRcode, there is a .png file.

        #return render_template("QR.html", user_image = full_filename)   #user_image is a variable in html file, so we just give the path to it.
        #return send_from_directory(app.config['UPLOAD_FOLDER'], filename=form_fname+".png", as_attachment=True) #use this function to directly enable the user to download the qr code!

        app.config['THEFILE'] = form_fname+".png"           #made a config to be used futher as filename

        return render_template("QR.html", user_image = full_filename , fname=app.config['THEFILE'])   #fname was given for uniquely identifying the url!
        
    elif request.method == "GET":               #If the user "gets: onto this page.
        return render_template("form.html")
Ejemplo n.º 2
0
def read(name):
    '''
    Read a QR code .png file
    :param name: name of file w/out .png
    :return: the info/data of the QR code
    '''
    code = QR()
    code.decode(name + ".png")
    return code.data
Ejemplo n.º 3
0
def form():
    if request.method == "POST":
        form_name = request.form["name"]
        form_phone = request.form["phone"]
        form_email = request.form["email"]
        form_fname = request.form["fname"]
        """ """
        warnings.filterwarnings("ignore")
        final_data = [('N', form_name), ('TEL', str("+91" + form_phone)),
                      ('EMAIL', form_email)]
        qr = QR(data=final_data,
                data_type='phonebook',
                level='h',
                margin_size=10,
                pixel_size=10)
        qr.encode()

        if not form_fname:  #checks string is null or no    #the user may or maynot give the filename, so we do this to store it.
            form_fname = "temp"

        form_fname = form_fname + str(time.time(
        ))  #this is done to work around the caching problem of flask.

        os.system(
            "mv " + qr.filename +
            str(" /home/AdityaSingh17/flask_onweb/static/QRcode/" +
                form_fname + ".png ")
        )  #relative moving, easy when we deploy. note /front_end will cause error

        full_filename = os.path.join(
            app.config['UPLOAD_FOLDER'],
            (form_fname + ".png"))  #under folder QRcode, there is a .png file.

        #return render_template("upload.html" , user_image = full_filename)

        app.config[
            'THEFILE'] = form_fname + ".png"  #made a config to be used futher in my file (for app.route("/form/QR"))

        app.config['THEURL'] = form_fname

        #return render_template("QR.html", user_image = full_filename)   #user_image is a variable in html file, so we just give the path to it.

        return render_template(
            "QR.html", user_image=full_filename, fname=app.config['THEFILE']
        )  #fname was given for uniquely identifying the url!

        #return qr.filename

        #return send_from_directory(app.config['UPLOAD_FOLDER'], filename=form_fname+".png", as_attachment=True) #use this function to directly enable the user to download the qr code!

    elif request.method == "GET":
        return render_template("form.html")
Ejemplo n.º 4
0
import pyqrcode
qr = pyqrcode.create("HORN O.K. PLEASE.")
qr.png("horn.png", scale=6)
from qrtools.qrtools import QR
qr = QR()
qr.decode("horn.png")
print(qr.data)
Ejemplo n.º 5
0
def form():
    if request.method == "POST":
        form_name = request.form["name"]
        form_phone = request.form["phone"]
        form_email = request.form["email"]
        form_fname = request.form["fname"]
        """ """
        warnings.filterwarnings("ignore")
        final_data = [('N', form_name), ('TEL', str("+91" + form_phone)),
                      ('EMAIL', form_email)]
        qr = QR(data=final_data,
                data_type='phonebook',
                level='h',
                margin_size=10,
                pixel_size=10)
        qr.encode()

        if not form_fname:  #checks string is null or no    #the user may or maynot give the filename, so we do this to store it.
            form_fname = "temp"

        form_fname = form_fname + str(time.time(
        ))  #this is done to work around the caching problem of flask.

        os.system(
            "mv " + qr.filename +
            str(" /home/AdityaSingh17/flask_onweb/static/QRcode/" +
                form_fname + ".png ")
        )  #relative moving, easy when we deploy. note /front_end will cause error

        #we moved the temp qr file to static folder, we used relative addressing, the cwd currently is /home/devillord17/Desktop/QR_Project

        #qrfilename = "~/Desktop/QR_Project/Front_end/static/"+form_fname+".png"
        #f = open("helloworld.html","wt")                                                                            #idhar edit kr be
        #f.write("<html><body><img src=\"{{ url_for('static', filename = '"+(form_fname+".png")+"') }}\" height=\"300\" width=\"200\"></body></html>")
        #f.write("<html><body><img src=\"../static/"+(form_fname+".png")+"\" height=\"300\" width=\"200\"></body></html>")
        #works if i dont move and directly just render the file.
        #os.system("mv ~/Desktop/QR_Project/helloworld.html ~/Desktop/QR_Project/Front_end/templates/helloworld.html")  #deosnt work when i move
        """
        this is v imp man, jan laga diya tha ye krne me. gand hi fat gaya ekdum.
        """

        full_filename = os.path.join(
            app.config['UPLOAD_FOLDER'],
            (form_fname + ".png"))  #under folder QRcode, there is a .png file.

        #full_filename = os.path.join(app.config['UPLOAD_FOLDER'], ("fc1.png"))    #under folder QRcode, there is a .png file.    #THIS IS WORKING, THAT MEANS THERE IS A PROBLEM IN MOVING! (PYTHONANYWHERE ONLY)
        #return render_template("upload.html" , user_image = full_filename)   #PYTHONANYWHERE ONLY EXAMPLE TO RENDER, IMAGE IS RENDERING, ONLY PROBLEM IS MOVING!!!!!!!!!!!!!!!!!!!

        app.config[
            'THEFILE'] = form_fname + ".png"  #made a config to be used futher in my file (for app.route("/form/QR"))

        app.config['THEURL'] = form_fname

        #return render_template("QR.html", user_image = full_filename)   #user_image is a variable in html file, so we just give the path to it.

        return render_template(
            "QR.html", user_image=full_filename, fname=app.config['THEFILE']
        )  #fname was given for uniquely identifying the url!

        #return qr.filename

        #return send_from_directory(app.config['UPLOAD_FOLDER'], filename=form_fname+".png", as_attachment=True) #use this function to directly enable the user to download the qr code!

    elif request.method == "GET":
        return render_template("form.html")
Ejemplo n.º 6
0
 def decodeQR(self, img):
     qr = QR(filename='QRCode1.png')
     qr.decode()
     print qr.data
Ejemplo n.º 7
0
def home():
    qr = QR(filename="./static/qrcode.png")
    qr.decode()
    print(qr.data)
    print(qr.data_type)
    print(qr.data_to_string())
Ejemplo n.º 8
0
from qrtools.qrtools import QR

qr = QR()
file = qr.decode("challenges.hackvent.hacking-lab.com.png")
print(file.data)
Ejemplo n.º 9
0
'''
### Reading and Generating QR codes in Python Using QRtools
-QR code, or quick response code, is a trademark for a type of 2 dimensional barcode.
-2 dimensional barcodes are similar to one dimensional barcodes, but can store more information per unit area.

# Generate a QR Code
    -qrtools contains a class QR (can be viewed in the source code),
    -for which we must initially create an object.
    -The object takes the following arguments

        1-> data
        2-> pixel_size
        3-> level
        4-> margin_size
        5-> data_type

'''
from qrtools.qrtools import QR

# Create or object
my_qr = QR(data=u"narsi")

# encodes to a qr code
my_qr.encode()