Python Web常见的框架

相关链接


  • Django:全能型Web框架
  • web.py:一个小巧的Web框架
  • Bottle:和Flask类似的Web框架
  • Tornado:Facebook的开源异步Web框架

Flask相关示例


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_form(): return '''

'''
@app.route('/signin', methods=['POST']) def signin(): # 需要从request对象读取表单内容: if request.form['username']=='admin' and request.form['password']=='password': return '

Hello, admin!

'
return '

Bad username or password.

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

Django的使用


$ pip3 install django

Python Web常见的框架_第1张图片

你可能感兴趣的:(python)