Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1769806
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: Python/Ruby

2016-05-11 10:52:40

文件结构
webapp_temlate.py
templates/
├── form.html
├── home.html
└── signok.html

webapp_temlate.py

点击(此处)折叠或打开

  1. #!/usr/bin/env python3
  2. #-*- coding:utf-8 -*-
  3. '''
  4. '''

  5. from flask import Flask
  6. from flask import request
  7. from flask import render_template


  8. app = Flask(__name__)

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

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

  15. @app.route('/signin',methods=['POST'])
  16. def signin():
  17.     username=request.form['username']
  18.     password=request.form['password']
  19.     if username == 'admin' and password == 'password':
  20.         return render_template('signok.html',username=username)
  21.     return render_template('form.html', message='Bad username and password', username=username)

  22. if __name__ == '__main__':
  23.     app.run()






阅读(1537) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~