标签:fas html import get color 用户 static 框架 secret
2018-11-17 18:38:42
开始学习进行玩前面项目 开始进军flask
flask是一个小型的web框架,,但是有很多第三方组件
最后组装组装就和django一样啦!!!!!!!
python install flask
from flask import Flask,render_template,request,redirect,session # app = Flask(__name__,template_folder="templates",static_folder="staticccc",static_url_path=‘/vvvvv‘) app = Flask(__name__,template_folder="templates",static_folder="static") app.secret_key = ‘asdfasdf‘ @app.route(‘/login‘,methods=["GET","POST"]) def login(): if request.method == ‘GET‘: return render_template(‘login.html‘) user = request.form.get(‘user‘) pwd = request.form.get(‘pwd‘) if user == ‘oldboy‘ and pwd == ‘666‘: session[‘user‘] = user return redirect(‘/index‘) return render_template(‘login.html‘,error=‘用户名或密码错误‘) # return render_template(‘login.html‘,**{"error":‘用户名或密码错误‘}) @app.route(‘/index‘) def index(): user = session.get(‘user‘) if not user: return redirect(‘/login‘) return render_template(‘index.html‘) if __name__ == ‘__main__‘: app.run()
标签:fas html import get color 用户 static 框架 secret
原文地址:https://www.cnblogs.com/zhen1996/p/9975194.html