-
#!/usr/bin/env python3
-
#-*- coding:utf-8 -*-
-
'''
-
'''
-
-
from flask import Flask
-
from flask import request
-
app = Flask(__name__)
-
-
@app.route('/', methods=['GET','POST'])
-
def home():
-
return '
home!
'
-
-
@app.route('/signin',methods=['GET'])
-
def signin_from():
-
return '''
-
-
-
Sign in
-
'''
-
-
@app.route('/signin',methods=['POST'])
-
def signin():
-
if request.form['username'] == 'admin' and request.form['password'] == 'password':
-
return '
hello admin!
'
-
return '
bad username and password.
'
-
-
if __name__ == '__main__':
-
app.run()
t@localhost untitled$ python3 webapp.py
* Running on
127.0.0.1 - - [10/May/2016 19:49:06] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [10/May/2016 19:49:06] "GET /favicon.ico HTTP/1.1" 404 -
127.0.0.1 - - [10/May/2016 19:49:23] "GET /signin HTTP/1.1" 200 -
127.0.0.1 - - [10/May/2016 19:49:39] "POST /signin HTTP/1.1" 200 -
127.0.0.1 - - [10/May/2016 19:49:52] "GET /signin HTTP/1.1" 200 -
127.0.0.1 - - [10/May/2016 19:49:57] "POST /signin HTTP/1.1" 200 -
直接输入网址
输入signin
用户名:admin,密码:password
用户名输入错误
阅读(1413) | 评论(0) | 转发(0) |