最近,趁着假期,复习了一遍以前学习到的python知识,和研究新的web框架Bottle,就写了个简单的登录页面,详细可以参考官方文档

不废话,直接上截图和代码:

代码如下:

#!/usr/bin/env python# -*- coding: utf-8 -*-import sysreload(sys)from bottle import request, route, run, template@route('/login', method='POST')def do_login():    username = request.forms.get('username')    password = request.forms.get('password')    print (username, password)    if username == 'admin' and password == 'admin':        return username + '登录成功'    else:        return username + '登陆失败'#用户登录@route('/index')def index():    return template('index')run(host='0.0.0.0', port=9090, debug=True)

前端代码:

    
    
login    
        用户名:
        密码:
        
    

最后,运行的结果是这样的: