每當我進入登錄站點(0.0.0.0:5000/)時,頁面立即恢復爲0.0.0.0:5000/admin。任何想法爲什麼發生這種情況?爲什麼我的代碼跳過我的索引頁?
在intel愛迪生上運行yocto。通過膩子編輯
@app.errorhandler(404)
@app.errorhandler(500)
def errorpage(e):
return render_template('404.html')
def login_required(f):
@wraps(f)
def wrap(*args, **kwargs):
if 'logged_in' in session:
return f(*args, **kwargs)
else:
flash('please login first.')
return redirect (url_for('index'))
return wrap
@app.route('/', methods=['GET','POST'])
def index():
error = None
if request.method == 'POST':
if request.form['username'] != 'admin' or request.form['password'] != 'password':
error = 'invalid attempt.'
else:
session['logged_in'] = True
return redirect(url_for('admin'))
return render_template('index.html', error = error)
@app.route('/logout')
def logout():
session.pop('logged_in', None)
return render_template('/logout.html')
@app.route('/admin',methods=['GET','POST'])
@login_required
def admin():
該圖像與選擇的字體大小和顏色的勉強可讀。請粘貼實際的代碼。 –
任何線索如何通過膩子複製和粘貼vi? – Zane
看看這是否有幫助:http://stackoverflow.com/questions/16741511/copy-from-putty-vim-visual-mode-to-windows-clipboard –