示例#1
0
def wdashboard():
    if request.method == "POST":
        user_id = request.form['userid']
        em_or_num = str(
            pybase64.b64encode(
                (request.form['em_or_num'].lower()).encode("utf-8")), "utf-8")
        manager_name = request.form['manager_name']
        mname = str(
            pybase64.b64encode(
                (request.form['manager_name'].lower()).encode("utf-8")),
            "utf-8")
        passwd = str(
            pybase64.b64encode((request.form['password']).encode("utf-8")),
            "utf-8")
        cur = getdbcur()
        sql = "select managerName from warehouse where (id = %s  AND (email = %s OR phoneNumber = %s ) AND managerName=%s AND password= %s ) "
        cur.execute(sql, (user_id, em_or_num, em_or_num, mname, passwd))
        sqlres = cur.rowcount
        mname = cur.fetchone()
        if sqlres == 1:
            session['user_id'] = user_id
            session['user_name'] = manager_name
            wareid = session['user_id']
            sql = 'select * from warehousenotification where warehouseId = "' + wareid + '"   '
            cur = getdbcur()
            cur.execute(sql)
            n = cur.rowcount
            if n > 0:
                session['notifcount'] = n
            return render_template('warehouse_dashboard.html')
        else:
            flash("Incorrect credentials!")
            return redirect(url_for('warehouse_login'))
    return redirect(url_for('warehouse_login'))
示例#2
0
def addcomment(blogid):
    if 'blogger_id' in session:
        userId = session['blogger_id']
        if request.method == 'POST':
            blogId = str(blogid)
            fullkey = uuid.uuid4()
            commentId = fullkey.time
            userName = str(
                pybase64.b64encode((session['blogger_name']).encode("utf-8")),
                "utf-8")
            comment = str(
                pybase64.b64encode((request.form['comment']).encode("utf-8")),
                "utf-8")
            cur = getblogcur()
            sql = 'insert into comments(blogId,commentId,userId,userName,comment) values(%s,%s,%s,%s,%s)'
            cur.execute(sql, (blogId, commentId, userId, userName, comment))
            n = cur.rowcount
            if n == 1:
                flash('Thanks for commenting !!!')
                return redirect(url_for('blog_post', blogid=blogId))
            flash('There is a error in adding new comment !!!')
            return redirect(url_for('blog_post', blogid=blogId))
        return redirect(url_for('blog_post', blogid=blogId))
    flash('You need to first login to add a comment !!')
    return redirect(url_for('blogger_login'))
示例#3
0
 def test_rating_put_true(self):
     tester = app.test_client(self)
     response = tester.put(
         '/student',
         headers={
             "Authorization":
             "Basic {user}".format(user=b64encode(b"Petro:12345").decode())
         },
         data=dict(email="gfbfffffffbgsfg", phone="eabffffffbdf"),
         follow_redirects=True)
     response = tester.put(
         '/student',
         headers={
             "Authorization":
             "Basic {user}".format(user=b64encode(b"Petro:12345").decode())
         },
         data=dict(email="gfbffffbgsfg", phone="eabbdf"),
         follow_redirects=True)
     # if
     data = json.loads(response.get_data(as_text=True))
     print(111111)
     print(data)
     print(data)
     print(data)
     print(data)
     print(112111)
     self.assertEqual('eabbdf', data['phone'])
示例#4
0
def changebloggerpass():
    if 'blogger_id' in session:
        usid = session['blogger_id']
        if request.method == 'POST':
            oldpass = str(
                pybase64.b64encode(
                    (request.form['oldPassword']).encode("utf-8")), "utf-8")
            newpass = str(
                pybase64.b64encode(
                    (request.form['newPassword']).encode("utf-8")), "utf-8")
            cpass = str(
                pybase64.b64encode(
                    (request.form['confirmPassword']).encode("utf-8")),
                "utf-8")
            if (newpass != cpass):
                return render_template(
                    'Blog/changebloggerpassword.html',
                    passmsg="new password and confirm password doesn't match.."
                )
            cur = getblogcur()
            cpasssql = "update blogger set password='******' where id = '" + usid + "' "
            cur.execute(cpasssql)
            n = cur.rowcount
            if n == 1:
                flash("password changed successfully !")
                session.pop('blogger_id', None)
                session.pop('blogger_name', None)
                return redirect(url_for('blogger_login'))
            return render_template(
                'Blog/changebloggerpassword.html',
                passmsg="New password is same as Old password")
        return render_template('Blog/changebloggerpassword.html')
    flash('Direct access to this page is Not allowed ..Login First!')
    return redirect(url_for('blogger_login'))
示例#5
0
def editblog(blogid):
    if request.method == 'POST':
        cur = getblogcur()
        blogimg = request.files['blogimg']
        if blogimg:
            checkphoto = "select blogImage from blogs where blogId='" + str(
                blogid) + "'"
            cur.execute(checkphoto)
            n = cur.rowcount
            if n == 1:
                prevphoto = cur.fetchone()
                photo = prevphoto[0]
                if photo != None:
                    os.remove("./static/photos/" + photo)
            path = os.path.basename(blogimg.filename)
            file_ext = os.path.splitext(path)[1][1:]
            imgfilename = str(uuid.uuid4()) + '.' + file_ext
            blogimgname = secure_filename(imgfilename)
            app = current_app._get_current_object()
            blogimg.save(os.path.join(app.config['UPLOAD_FOLDER'],
                                      blogimgname))
            title = str(
                pybase64.b64encode(
                    (request.form['title'].replace('\r\n',
                                                   '<br>')).encode("utf-8")),
                "utf-8")
            content = str(
                pybase64.b64encode(
                    (request.form['content'].replace('\r\n',
                                                     '<br>')).encode("utf-8")),
                "utf-8")
            sql = 'update blogs set blogImage = %s , title = %s , content = %s where blogId = %s'
            cur.execute(sql, (blogimgname, title, content, str(blogid)))
            n = cur.rowcount
            if n == 1:
                flash('Your blog is successfully edited !!')
                return redirect(url_for('blog_post', blogid=str(blogid)))
            flash('There is some problem. Try again Later !!')
            return redirect(url_for('blog_post', blogid=str(blogid)))
        else:
            title = str(
                pybase64.b64encode(
                    (request.form['title'].replace('\r\n',
                                                   '<br>')).encode("utf-8")),
                "utf-8")
            content = str(
                pybase64.b64encode(
                    (request.form['content'].replace('\r\n',
                                                     '<br>')).encode("utf-8")),
                "utf-8")
            sql = 'update blogs set  title = %s , content = %s where blogId = %s'
            cur.execute(sql, (title, content, str(blogid)))
            n = cur.rowcount
            if n == 1:
                flash('Your blog is successfully edited !!')
                return redirect(url_for('blog_post', blogid=str(blogid)))
            flash('There is some problem. Try again Later !!')
            return redirect(url_for('blog_post', blogid=str(blogid)))
    return redirect(url_for('blog_post', blogid=str(blogid)))
    def _compress(cls, x, isbytes=False):
        """Compress the line.

        This function reduces IO overhead to speed up the program.
        """
        if isbytes:
            return pybase64.b64encode(lz4.frame.compress(x)) + b'\n'
        return pybase64.b64encode(lz4.frame.compress(x.encode())) + b'\n'
示例#7
0
def encode(pw):
    y = pybase64.b64encode(pw.encode('utf-8'))
    y = y[::-1]
    y = parse.quote(y)
    y = parse.quote(y)
    y = parse.quote(y)
    y = pybase64.b64encode(y.encode('utf-8'))
    return y.decode('utf-8')
示例#8
0
def compress(x, isbytes=False):
    """Compress the line.

    This function reduces IO overhead to speed up the program.
    """
    if isbytes:
        return pybase64.b64encode(lz4.frame.compress(x, compression_level=0))+b'\n'
    return pybase64.b64encode(lz4.frame.compress(x.encode(), compression_level=-1))+b'\n'
示例#9
0
def addproducer():
    if 'user_id' in session:
        warehouseid = str(session['user_id'])
        cbar = countbar(warehouseid)
        if request.method == 'POST':
            fullkey = uuid.uuid4()
            uid = fullkey.time
            name = str(
                pybase64.b64encode(
                    (request.form['name'].lower()).encode("utf-8")), "utf-8")
            phoneNumber = str(
                pybase64.b64encode(
                    (request.form['phoneNumber'].lower()).encode("utf-8")),
                "utf-8")
            email = str(
                pybase64.b64encode(
                    (request.form['email'].lower()).encode("utf-8")), "utf-8")
            gender = str(
                pybase64.b64encode(
                    (request.form['gender'].lower()).encode("utf-8")), "utf-8")
            age = str(
                pybase64.b64encode(
                    (request.form['age'].lower()).encode("utf-8")), "utf-8")
            address = str(
                pybase64.b64encode(
                    (request.form['address'].lower()).encode("utf-8")),
                "utf-8")
            commodityType = str(
                pybase64.b64encode(
                    (request.form['commodityType'].lower()).encode("utf-8")),
                "utf-8")
            commodityUnits = str(
                pybase64.b64encode(
                    (request.form['commodityUnits'].lower()).encode("utf-8")),
                "utf-8")
            aadharNumber = str(
                pybase64.b64encode(
                    (request.form['aadharNumber'].lower()).encode("utf-8")),
                "utf-8")
            addquery = 'insert into producer values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'
            cur = getdbcur()
            cur.execute(
                addquery,
                (uid, name, age, gender, phoneNumber, email, address,
                 commodityType, commodityUnits, aadharNumber, warehouseid))
            n = cur.rowcount
            if (n == 1):
                flash(' New Producer details added!')
                return redirect(url_for('producer'))
            else:
                return render_template(
                    'producers.html',
                    pmsg='Adding new producer details failed!',
                    cbar=cbar)
        return render_template('producers.html', cbar=cbar)
    flash('Direct access to this page is Not allowed !')
    return redirect(url_for('warehouse_login'))
示例#10
0
def changeproducer():
    if 'user_id' in session:
        if request.method == 'POST':
            id = request.form['id']
            name = str(
                pybase64.b64encode(
                    (request.form['name'].lower()).encode("utf-8")), "utf-8")
            email = str(
                pybase64.b64encode(
                    (request.form['email'].lower()).encode("utf-8")), "utf-8")
            number = str(
                pybase64.b64encode(
                    (request.form['phoneNumber'].lower()).encode("utf-8")),
                "utf-8")
            gender = str(
                pybase64.b64encode(
                    (request.form['gender'].lower()).encode("utf-8")), "utf-8")
            age = str(
                pybase64.b64encode(
                    (request.form['age'].lower()).encode("utf-8")), "utf-8")
            address = str(
                pybase64.b64encode(
                    (request.form['address'].lower()).encode("utf-8")),
                "utf-8")
            commoditytype = str(
                pybase64.b64encode(
                    (request.form['commodityType'].lower()).encode("utf-8")),
                "utf-8")
            commodityunits = str(
                pybase64.b64encode(
                    (request.form['commodityUnits'].lower()).encode("utf-8")),
                "utf-8")
            aadharNumber = str(
                pybase64.b64encode(
                    (request.form['aadharNumber'].lower()).encode("utf-8")),
                "utf-8")
            editquery = 'update producer set name =%s,emailId=%s,contactNumber=%s,commodityType=%s,commodityUnits=%s, age=%s, gender=%s, address=%s,aadharNumber=%s where unique_key=%s '
            cur = getdbcur()
            cur.execute(editquery,
                        (name, email, number, commoditytype, commodityunits,
                         age, gender, address, aadharNumber, id))
            n = cur.rowcount
            if n == 1:
                flash('producers Details changed Successfully !')
                return redirect(url_for('producer'))
            else:
                flash('Nothing will be changed in producers details !')
                return redirect(url_for('producer'))
        return redirect(url_for('producer'))
    flash(
        'Direct access to this page is Not Alloed Login first To view this page!'
    )
    return redirect(url_for('warehouse_login'))
示例#11
0
def resoutletpass():
    if request.method == 'POST':
        user_id = request.form['id']
        verifcode = request.form['verifcode']
        passwd = str(
            pybase64.b64encode((request.form['pass']).encode("utf-8")),
            "utf-8")
        if (verifcode == None):
            flash("please fill out the verification code")
            return redirect(url_for('reset_password'))
        cur = getoutletcur()
        idquery = 'select managerName from outlet where id= "' + user_id + '" AND resetcode = "' + verifcode + '"  '
        cur.execute(idquery)
        m = cur.rowcount
        if m == 1:
            resquery = ' update outlet set password = %s  where (id = %s  AND resetcode = %s) '
            cur.execute(resquery, (passwd, user_id, verifcode))
            n = cur.rowcount
            if n == 1:
                delquery = ' update outlet set resetcode = %s  where id = %s '
                cur.execute(delquery, (uuid.uuid4().hex, user_id))
                flash('Your password is Changed ..You can now Login!')
                return redirect(url_for('outlet_login'))
            else:
                return render_template(
                    'Outlet/reset_outlet_password.html',
                    samepassmsg=
                    "You password is same as previous One..login from below")
        else:
            return render_template(
                'Outlet/reset_outlet_password.html',
                rmsg=
                "Either unique Id or verification code is incorrect.. please try again!"
            )
    return render_template('Outlet/reset_outlet_password.html')
示例#12
0
def searchclient():
    if 'outlet_id' in session:
        if request.method == 'POST':
            outletid = str(session['outlet_id'])
            si = str(
                pybase64.b64encode(
                    (request.form['searchinp'].lower()).encode("utf-8")),
                "utf-8")
            searchquery = "select * from clients where (name like  '%" + si + "%'  OR commodityPurchased like   '%" + si + "%' )  and outletid = '" + outletid + "' "
            cur = getoutletcur()
            cur.execute(searchquery)
            n = cur.rowcount
            if n >= 1:
                data = cur.fetchall()
                cd = [list(i) for i in data]
                for i in range(0, len(cd)):
                    for j in range(1, len(cd[i]) - 1):
                        cd[i][j] = str(pybase64.b64decode(cd[i][j]), "utf-8")
                td = tuple(tuple(i) for i in cd)
                return render_template('Outlet/outlet_clients.html',
                                       pdata=td,
                                       pmsg="Search Results!")
            else:
                return render_template(
                    'Outlet/outlet_clients.html',
                    pmsg="No results for search..try different key!")
        else:
            return render_template('Outlet/outlet_clients.html',
                                   pmsg="Enter something to search!")
    flash('You must login first to view Clients!')
    return redirect(url_for('outlet_login'))
示例#13
0
    def post(self):
        data = tornado.escape.json_decode(self.request.body)
        for d in data['progress_bars']:
            data[d['name']] = d['value']
        for d in data['check_boxes']:
            data[d['name']] = d['checked']
        image_data = data['frame'].replace('data:image/jpeg;base64,', "")
        byte_image = io.BytesIO(pybase64._pybase64.b64decode(image_data))
        img_input = Image.open(byte_image)
        model_key = data['model_name']
        if model_key not in camera_models:
            if model_key not in model_paths:
                raise Exception("Model {} not found.".format(model_key))
            model_path = model_paths[model_key]['path']
            model = torch.load(model_path).eval().cuda()
            model.preprocessing = augmentation.PairCompose([
                augmentation.PaddTransform(pad_size=2**model.depth),
                augmentation.OutputTransform()
            ])
            camera_models[model_key] = model.cuda()
        model = camera_models[model_key]
        img_tensor, _, _ = model.preprocessing(img_input, None, None)
        img_tensor = img_tensor.unsqueeze(0).float().cuda()
        output = model(img_tensor).detach()[
            0,
            0, :img_input.size[1], :img_input.size[0]].sigmoid().cpu().numpy()

        mask_byte_arr = io.BytesIO()
        Image.fromarray((output * 255).astype('uint8')).save(mask_byte_arr,
                                                             format='jpeg')
        encoded_mask = 'data:image/jpeg;base64,' + pybase64.b64encode(
            mask_byte_arr.getvalue()).decode('utf-8')
        self.write(tornado.escape.json_encode(encoded_mask))
示例#14
0
def outletforget():
    if request.method == 'POST':
        user_id = request.form['id']
        em = request.form['email']
        email = str(pybase64.b64encode((em).encode("utf-8")), "utf-8")
        randcode = randint(100000, 999999)  #Generating 6 digit random int
        sql = ' update outlet set resetcode = %s where (id = %s  AND email = %s) '
        cur = getoutletcur()
        cur.execute(sql, (randcode, user_id, email))
        n = cur.rowcount
        if n == 1:
            #getting mail app with app
            app = current_app._get_current_object()
            mail = Mail(app)
            subject = "verification code for account"
            msg = Message(subject,
                          sender='*****@*****.**',
                          recipients=[str(em)])
            msg.body = "Your verification code  is " + str(
                randcode) + " after input you have to change your password!!"
            mail.send(msg)
            flash('Check your verification code in your email')
            return redirect(url_for('reset_outlet_password'))
        else:
            return render_template(
                'Outlet/forgot_outlet_password.html',
                fmsg="Either unique Id or email is incorrect..try again!")
    return render_template('Outlet/forgot_outlet_password.html')
示例#15
0
def test_get_blob_md5():
    mock_md5 = mock.MagicMock()
    mock_md5.md5_hash = pybase64.b64encode(b"foobar")
    google_storage = GoogleStorage("test", None)
    google_storage.bucket = mock.MagicMock()
    google_storage.bucket.get_blob.return_value = mock_md5
    assert google_storage.get_blob_md5("test.txt") == "666f6f626172"
示例#16
0
async def inline_id_handler(event: events.InlineQuery.Event):

    builder = event.builder
    me = await client.get_me()
    if event.query.user_id == me.id:
        if event.pattern_match.group(1) == "en":
            lething = str(
                pybase64.b64encode(bytes(event.pattern_match.group(2),
                                         "utf-8")))[2:]

            resultm = builder.article(title="Encoded",description="en",text="Encoded: `" + lething[:-1] + "`",buttons=[[Button.switch_inline("Search Again", query="base64 ", same_peer=True)],], )
            await event.answer([resultm])
            return

        else:
            lething = str(
                pybase64.b64decode(bytes(event.pattern_match.group(2), "utf-8"),
                                   validate=True))[2:]
            resultm = builder.article(title="Decoded",description="de",text="Decoded: `" + lething[:-1] + "`",buttons=[[Button.switch_inline("Search Again", query="base64 ", same_peer=True)],], )
            await event.answer([resultm])
            return
    if not event.query.user_id == me.id:
        resultm = builder.article(title="me not your bot",description="Mind Your Business",text="Hey U Must Use https://github.com/Sh1vam/javes-3.0  ",buttons=[[Button.switch_inline("Search Again", query="base64 ", same_peer=True)],], )
        await event.answer([resultm])
        return
示例#17
0
 def test_rnd(self, altchars_id, vector_id, validate, ualtchars, simd_id):
     self.simd_setup(simd_id)
     vector = test_vectors_b64[altchars_id][vector_id]
     altchars = altchars_lut[altchars_id]
     self.assertEqual(
         pybase64.b64encode(pybase64.b64decode(vector, altchars, validate),
                            altchars_lut[altchars_id]), vector)
示例#18
0
def buildWordCloud(replies):
    #    try:
    words = ''
    for i in range(0, len(replies)):
        words = words + ''.join(replies[i].full_text.strip().replace(
            "\r", "").replace("\n", "").replace(
                "@" + replies[i].in_reply_to_screen_name, ""))
    #print(words)
    if len(words) > 0:
        words = cleanUpTweet(words)
        # Creating a word cloud
        stopwords = set(STOPWORDS)
        print("Words: " + words)
        wordCloud = WordCloud(width=600,
                              height=400,
                              max_words=200,
                              stopwords=stopwords,
                              background_color='white',
                              random_state=1).generate(words)
        # GEHEIM-TIP! - "plt.switch_backend('agg')" damit ich "matplotlib" auch in Flask nutzen kann.
        plt.switch_backend('agg')
        plt.imshow(wordCloud, interpolation='bilinear')
        plt.axis("off")
        buf = BytesIO()
        plt.savefig(buf, format="png")
        # Embed the result in the html output.
        data = pybase64.b64encode(buf.getbuffer()).decode("ascii")
        return data
    else:
        return None
示例#19
0
async def endecrypt(e):
	if e.pattern_match.group(1) == 'en':
		lething=str(pybase64.b64encode(bytes(e.pattern_match.group(2), 'utf-8')))[2:]
		await e.reply('Encoded: `' + lething[:-1] + '`')
	else:
		lething=str(pybase64.b64decode(bytes(e.pattern_match.group(2), 'utf-8'), validate=True))[2:]
		await e.reply('Decoded: `' + lething[:-1] + '`')
示例#20
0
def searchproducer():
    if 'user_id' in session:
        warehouseid = str(session['user_id'])
        cbar = countbar(warehouseid)
        if request.method == 'POST':
            si = str(
                pybase64.b64encode(
                    (request.form['searchinp'].lower()).encode("utf-8")),
                "utf-8")
            searchquery = "select * from producer where (name like  '%" + si + "%'  OR commodityType like   '%" + si + "%' )  and warehouseid = '" + warehouseid + "' "
            cur = getdbcur()
            cur.execute(searchquery)
            n = cur.rowcount
            if n >= 1:
                data = cur.fetchall()
                cd = [list(i) for i in data]
                for i in range(0, len(cd)):
                    for j in range(1, len(cd[i]) - 1):
                        cd[i][j] = str(pybase64.b64decode(cd[i][j]), "utf-8")
                td = tuple(tuple(i) for i in cd)
                return render_template('producers.html',
                                       pdata=td,
                                       pmsg="Search Results!",
                                       cbar=cbar)
            else:
                return render_template(
                    'producers.html',
                    pmsg="No results for search..try different key!",
                    cbar=cbar)
        else:
            return render_template('producers.html',
                                   pmsg="Enter something to search!",
                                   cbar=cbar)
    flash('You must login first to view Producers!')
    return redirect(url_for('warehouse_login'))
示例#21
0
    def vision_image_manager(latest_file):
        # Instantiates a client

        service = discovery.build('vision', 'v1')
        # text.png is the image file.
        with open(latest_file, 'rb') as image:
            image_content = base64.b64encode(image.read())
            service_request = service.images().annotate(
                body={
                    "requests": [{
                        "image": {
                            "content": image_content.decode('UTF-8')
                        },
                        "features": [{
                            "type": "LABEL_DETECTION",
                            "maxResults": 3,
                            "latLongRect": {object(LatLongRect)}
                        }]
                    }]
                })

            response = service_request.execute()
            print(response['responses'])
            res_dict = dict(response)
            return res_dict
示例#22
0
def register():
    # Output message if something goes wrong...
    msg = ''
    if('loggedin' not in session):
    # Check if "username", "password" and "email" POST requests exist (user submitted form)
        if request.method == 'POST' and 'username' in request.form and 'password' in request.form and 'email' in request.form:
            # Create variables for easy access
            username = request.form['username']
            password = request.form['password']
            email = request.form['email']
            full_name = request.form['full_name']
            address = request.form['address']
            age = request.form['age']
            blood = request.form['blood']
            if(username and password and email and full_name and address and age and blood):
                # Check if account exists using MySQL
                cursor = mysql.get_db().cursor()
                cursor.execute('SELECT * FROM users WHERE Username = %s', (username))
                account = cursor.fetchone()
                # If account exists show error and validation checks
                if account:
                    msg = 'Account already exists!'
                    flash(msg)
                elif not re.match(r'[^@]+@[^@]+\.[^@]+', email):
                    msg = 'Invalid email address!'
                    flash(msg)
                elif not re.match(r'[A-Za-z0-9]+', username):
                    msg = 'Username must contain only characters and numbers!'
                    flash(msg)
                else:
                    # Account doesnt exists and the form data is valid, now insert new account into users table
                    apistr = username;
                    result = hashlib.md5(apistr.encode()) 
                    comb = username+'(~)'+password
                    s = comb.encode()
                    s1 = pybase64.b64encode(s)
                    api=s1.decode('utf-8')
                    hashed_password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt())
                    cursor.execute('INSERT INTO users VALUES (NULL, %s, %s, %s, %s, %s, %s, %s, %s)', (username, hashed_password, email, full_name, address, blood, age, api))
                    cursor.execute('SELECT * FROM users WHERE Username = %s', (username))
                    # Fetch one record and return result
                    account = cursor.fetchone()
                    session['loggedin'] = True
                    session['id'] = account[0]
                    session['username'] = account[1]
                    session['api'] = account[8]
                    session['isdoctor'] = 0
                    msg = 'You have successfully registered!'
                    return home()
            else:
                msg = 'Please fill out the form!'
                flash(msg)
        elif request.method == 'POST':
            # Form is empty... (no POST data)
            msg = 'Please fill out the form!'
        # Show registration form with message (if any)
    else:
        return home()
    return render_template('patientlogin.html', msg=msg)
示例#23
0
 def get_table_download_link_csv(df):
     import pybase64
     #csv = df.to_csv(index=False)
     csv = df.to_csv().encode()
     #b64 = base64.b64encode(csv.encode()).decode()
     b64 = pybase64.b64encode(csv).decode()
     href = f'<a href="data:file/csv;base64,{b64}" download="captura.csv" target="_blank">Download csv file</a>'
     return href
示例#24
0
def get_table_download_link(df):
    """Generates a link allowing the data in a given panda dataframe to be downloaded
    in:  dataframe
    out: href string
    """
    val = to_excel(df)
    b64 = pybase64.b64encode(val)  # val looks like b'...'
    return f'<a href="data:application/octet-stream;base64,{b64.decode()}" download="extract.xlsx">Download excel file</a>'  # decode b'abc' => abc
示例#25
0
 def password_and_timestamp(self, shortcode, passkey, timestamp):
     """Processs the current time and generate test password and timestamp"""
     timestamp = str(timestamp.strftime("%Y%m%d%H%M%S"))
     password = '******' + config.passkey + timestamp
     password = b64encode(bytes(password, 'utf-8'))
     password = password.decode("utf-8")
     data = {'password': password, 'timestamp': timestamp}
     return data
示例#26
0
def getJson(img):
    file_object = io.BytesIO()
    img.save(file_object, "PNG")
    file_object.seek(0)
    base64image = (pybase64.b64encode(file_object.getvalue(),
                                      altchars="_:")).decode("utf-8")
    response = {"Completion_Status": "Success", "Image": base64image}
    return jsonify(response)  # send the result to client
示例#27
0
def get_table_download_link(df):
    """Generates a link allowing the data in a given panda dataframe to be downloaded
    in:  dataframe
    out: href string
    """
    csv = df.to_csv(index=False)
    b64 = pybase64.b64encode(csv.encode()).decode(
    )  # some strings <-> bytes conversions necessary here
    return f'<a href="data:file/csv;base64,{b64}" download="Prediction.csv">⬇️ Download output CSV File</a>'
 def encrypt_and_compress(self):
     plain_text = self.pad(self.data)
     iv = random().read(AES.block_size)
     cipher = AES.new(self.key, AES.MODE_OFB, iv)
     data = b64encode(iv + cipher.encrypt(plain_text.encode()))
     if self.compression is False:
         return data.decode("utf-8")
     compressed_data = zlib.compress(data)
     return compressed_data
示例#29
0
		def send():
			msg = f"Usted => {self.e.get()}"
			self.txt.insert(END,"\n"+msg)

			b = self.e.get().encode("UTF-8")
			msg = pybase64.b64encode(b)
			self.send_msg(msg)

			self.e.delete(0,END)
示例#30
0
def addblog():
    if 'blogger_id' in session:
        ownerid = session['blogger_id']
        if request.method == 'POST':
            ownername = str(
                pybase64.b64encode((session['blogger_name']).encode("utf-8")),
                "utf-8")
            d = str(pybase64.b64encode((str(date.today())).encode("utf-8")),
                    "utf-8")
            fullkey = uuid.uuid4()
            blogId = fullkey.time
            title = str(
                pybase64.b64encode(
                    (request.form['title'].replace('\r\n',
                                                   '<br>')).encode("utf-8")),
                "utf-8")
            content = str(
                pybase64.b64encode(
                    (request.form['content'].replace('\r\n',
                                                     '<br>')).encode("utf-8")),
                "utf-8")
            img = request.files['blogimg']
            path = os.path.basename(img.filename)
            file_ext = os.path.splitext(path)[1][1:]
            imgfilename = str(uuid.uuid4()) + '.' + file_ext
            blogimg = secure_filename(imgfilename)
            cur = getblogcur()
            insertblogsql = 'insert into blogs(blogId,ownerId,blogImage,title,content,ownerName,date) values (%s,%s,%s,%s,%s,%s,%s) '
            cur.execute(
                insertblogsql,
                (blogId, ownerid, blogimg, title, content, ownername, d))
            n = cur.rowcount
            if n == 1:
                app = current_app._get_current_object()
                img.save(os.path.join(app.config['UPLOAD_FOLDER'], blogimg))
                flash('Blog Added Successully !')
                return redirect(url_for('blogs'))
            flash(
                'There is a problem while adding the Blog. Try again Later !!')
            return redirect(url_for('blogs'))
        return redirect(url_for('blogs'))
    flash('Direct access to this page is Not allowed ..Login First!')
    return redirect(url_for('blogger_login'))