def main(): config = get_config() url = f"{config['url']}/{config['bot_token']}" requests.post(get_url("setWebhook"), data={"url": url}) r = requests.get(get_url("getWebhookInfo")) pprint(r.status_code) pprint(r.json())
def sys_profile_edit(): ip = request.remote_addr x = request.form if 'token' not in session: return render_template('message.html', cont='3') req = { 'method': 'profile.edit', 'token': session['token'], 'ip': ip, } for i in ('name', 'surname', 'description'): #mail #password if i in x: req[i] = x[i] if i == 'description': req[i] = x[i].replace('\r', '').replace('\n', '<br>') if 'photo' in request.files: y = request.files['photo'].stream.read() y = str(base64.b64encode(y))[2:-1] req['photo'] = y req['file'] = request.files['photo'].filename req = json.loads(post(LINK, json=req).text) if not req['error']: return get_url(request.args.get('url')) else: return render_template('message.html', cont=req['message'])
def test_get_url(self): company_name = "Innovex" regex = re.compile( r'^(?:http|ftp)s?://' # http:// or https:// r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' #domain... r'localhost|' #localhost... r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip r'(?::\d+)?' # optional port r'(?:/?|[/?]\S+)$', re.IGNORECASE) self.assertIsNotNone(re.match(regex, get_url(company_name)))
def settings(): x = request.form if 'token' not in session: return render_template('message.html', cont='3') req = {'cm': 'profile.settings', 'token': session['token']} for i in ('name', 'surname', 'description'): #mail #password if i in x: req[i] = x[i] req = post(LINK, json=req).text if req != '0' and len(req) < 3: return render_template('message.html', cont=req) return get_url(request.args.get('url'))
def signin(): x = request.form if not all([i in x for i in ('login', 'pass')]): return render_template('message.html', cont='3') req = post(LINK, json={'method': 'profile.auth', 'login': x['login'], 'pass': x['pass']}).text if len(req) <= 3: return render_template('message.html', cont=req) req = loads(req) session['token'] = req['token'] session['id'] = req['id'] return get_url(request.args.get('url'))
def settings(): x = request.form if 'token' not in session: return render_template('message.html', cont='3') req = {'method': 'profile.edit', 'token': session['token']} for i in ('name', 'surname', 'description'): #mail #password if i in x: req[i] = x[i] if 'photo' in request.files: y = request.files['photo'].stream.read() y = str(base64.b64encode(y))[2:-1] req['photo'] = y req['file'] = request.files['photo'].filename req = post(LINK, json=req).text if req != '0' and len(req) < 3: return render_template('message.html', cont=req) return get_url(request.args.get('url'))
def signin(): ip = request.remote_addr x = request.form if not all([i in x for i in ('login', 'pass')]): return render_template('message.html', cont='3') req = { 'method': 'profile.auth', 'ip': ip, 'login': x['login'], 'pass': x['pass'], } req = json.loads(post(LINK, json=req).text) if not req['error']: session['token'] = req['token'] session['id'] = req['id'] return get_url(request.args.get( 'url')) # get_url('token/?url=' + request.args.get('url')) else: return render_template('message.html', cont=req['message'])
def _test_get_url(url, args, info): assert (url == get_url(args, info))