|
老师好:按照您的代码写好了,登陆网页报错如图:
# -*- coding: utf-8 -*-from flask import Flask, request, session, g, redirect, url_for, abort, \ render_template, flash, _app_ctx_stackSECRET_KEY = 'development key'# create our little application app = Flask(__name__)app.config.from_object(__name__)app.config.from_envvar('FLASKR_SETTINGS', silent=True)@app.route('/login', methods=['GET', 'POST'])def login(): error = None if request.method == 'POST': if request.form.get('username') !="12345": #if request.form['username'] != "12345": error = 'Invalid username' #elif request.form['password'] != "12345": elif request.form.get('password') !="12345": error = 'Invalid password' else: session['logged_in'] = True return redirect(url_for('login_ok')) return render_template('login.html', error=error)@app.route('/login_ok', methods=['GET', 'POST'])def login_ok(): return render_template('login_ok.html')@app.route('/logout')def logout(): session.pop('logged_in', None) return render_template('login_out.html')if __name__ == '__main__': app.run()
在学课程 接口自动化测试平台测试开发
|
|