python flask学习笔记

在pycharm中运行时候,需要将上次运行的窗口停掉。不然,新改的密码是无法出来的
from flask import Flask,request,render_template

app = Flask(name)

@app.route('/', methods=['GET', 'POST'])
def home():
return render_template('home.html')

@app.route('/signin', methods=['GET'])
def signin_form():
return render_template('form.html')

@app.route('/signin', methods=['POST'])
def signin():
username = request.form['username']
password = request.form['password']
if username == 'admin' and password =='password':
return render_template('signin-ok.html',username=username)
return render_template('form.html', message='bad username or password',username=username)

if name == 'main':
app.run()

posted @ 2019-10-13 21:39  堕落先锋  阅读(142)  评论(0编辑  收藏  举报