Beispiel #1
0
def goto(target):
    goto = get_url(target)
    if goto:
        if goto.find('http://') != 0 and goto.find('https://') != 0:
            goto = 'https://' + goto
        return redirect(goto)
    else:
        url = 'http://' + HOST + '/' + target
        return render_template('erro_nourl.html', url=url)
Beispiel #2
0
def login():
    usr=request.form.get('name_l','')
    psd=request.form.get('psd_l','')
    if search_user(usr):
        if valid_psd(usr,psd):
            session['name']=usr
            session['url']=''
            try:
                url=get_url(usr)
                session['url']=url
            except FileNotFoundError:
                pass
            session.permanent=True
            print('成功登录')
            return redirect(url_for('first_blue.setting'))
        else:
            flash('密码不正确',category='error')
    else:
        if usr=='':
            pass
        else:
            flash("用户名未注册",category='error')
    return render_template('login.html')
Beispiel #3
0
 def get(self):
     key = self.request.get('key')
     url = models.get_url(key)
     url.delete()
     self.redirect("/admin/view/urls")