Flask插件

Flask的插件有很多,本文主要是對其中流行的(approved)的插件進行簡單的展示。

Flask-Babel

Adds i18n/l10n support to Flask, based on babel and pytz.

Flask-Bcrypt

Bcrypt support for hashing passwords

Flask-CouchDB

Adds CouchDB support to Flask.

Flask-Creole

Creole parser filters for Flask.

Flask-Dance

Doing the OAuth dance with style using Flask, requests, and oauthlib.

Flask-Exceptional

Adds Exceptional support to Flask applications

Flask-FlatPages

Provides flat static pages to a Flask application, based on text files as opposed to a relational database.

Flask-Genshi

Adds support for the Genshi templating language to Flask applications.

Flask-Login

Flask-Login provides user session management for Flask. It handles the common tasks of logging in, logging out, and remembering your users' sessions over extended periods of time.

Flask-Mail

Makes sending mails from Flask applications very easy and has also support for unittesting.

Flask-Misaka

A simple extension to integrate the Misaka module for efficiently parsing Markdown.

Flask-RESTful

Flask-RESTful provides the building blocks for creating a great REST API.

from flask import Flask, request
from flask_restful import Resource, Api, reqparse, abort

app = Flask(__name__)
api = Api(app)

TODOS = {
    'todo1': {'task': 'build an API'},
    'todo2': {'task': '?????'},
    'todo3': {'task': 'profit!'},
}


def abort_if_todo_doesnt_exists(todo_id):
    if todo_id not in TODOS:
        abort(404, message="Todo {} doesn't exist".format(todo_id))


parser = reqparse.RequestParser()
parser.add_argument('task', type=str)


class Todo(Resource):
    def get(self, todo_id):
        abort_if_todo_doesnt_exists(todo_id)
        return TODOS[todo_id]

    def delete(self, todo_id):
        abort_if_todo_doesnt_exists(todo_id)
        del TODOS[todo_id]
        return '', 204

    def put(self, todo_id):
        args = parser.parse_args()
        task = {'task': args['task']}
        TODOS[todo_id] = task
        return task, 201


class TodoList(Resource):
    def get(self):
        return TODOS

    def post(self):
        args = parser.parse_args()
        todo_id = int(max(TODOS.keys()).lstrip('todo')) + 1
        todo_id = 'todo{}'.format(todo_id)
        TODOS[todo_id] = {'task': args['task']}
        return TODOS[todo_id], 201


api.add_resource(TodoList, '/todos')
api.add_resource(Todo, '/todos/<todo_id>')


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

Flask-Restless

Flask-Restless provides simple generation of ReSTful APIs for database models defined using Flask-SQLAlchemy. The generated APIs send and receive messages in JSON format.

Flask-Script

The Flask-Script extension provides support for writing external scripts in Flask. It uses argparse to parse command line arguments.

Flask-SeaSurf

SeaSurf is a Flask extension for preventing cross-site request forgery (CSRF).

Flask-SQLAlchemy

Add SQLAlchemy support to Flask with automatic configuration and helpers to simplify common web use cases. Major features include:

  • Handle configuring one or more database connections.
  • Set up sessions scoped to the request/response cycle.
  • Time queries and track model changes for debugging.

Flask-SSE

Server Sent Events for Flask.

Flask-Testing

The Flask-Testing extension provides unit testing utilities for Flask.

Flask-Themes

Flask-Themes makes it easy for your application to support a wide range of appearances.

Flask-Uploads

Flask-Uploads allows your application to flexibly and efficiently handle file uploading and serving the uploaded files. You can create different sets of uploads - one for document attachments, one for photos, etc.

Flask-User

Customizable User Account Management for Flask: Register, Confirm email, Login, Change username, Change password, Forgot password, Role-based Authorization and Internationalization.

Flask-WTF

Flask-WTF offers simple integration with WTForms. This integration includes optional CSRF handling for greater security.

Flask-XML-RPC

Adds XML-RPC support to Flask.

Flask-ZODB

Use the ZODB with Flask

Frozen-Flask

Freezes a Flask application into a set of static files. The result can be hosted without any server-side software other than a traditional web server.

另外也有一些雖然不是approved朋沮,但也很常用的插件

Flask-Migrate

SQLAlchemy database migrations for Flask applications using Alembic. The database operations are provided as command line arguments forFlask-Script.

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市阐虚,隨后出現(xiàn)的幾起案子烟勋,更是在濱河造成了極大的恐慌,老刑警劉巖拂盯,帶你破解...
    沈念sama閱讀 217,907評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件佑女,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機团驱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,987評論 3 395
  • 文/潘曉璐 我一進店門摸吠,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人嚎花,你說我怎么就攤上這事寸痢。” “怎么了紊选?”我有些...
    開封第一講書人閱讀 164,298評論 0 354
  • 文/不壞的土叔 我叫張陵啼止,是天一觀的道長。 經(jīng)常有香客問我兵罢,道長献烦,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,586評論 1 293
  • 正文 為了忘掉前任卖词,我火速辦了婚禮巩那,結果婚禮上,老公的妹妹穿的比我還像新娘此蜈。我一直安慰自己即横,他們只是感情好,可當我...
    茶點故事閱讀 67,633評論 6 392
  • 文/花漫 我一把揭開白布裆赵。 她就那樣靜靜地躺著东囚,像睡著了一般。 火紅的嫁衣襯著肌膚如雪顾瞪。 梳的紋絲不亂的頭發(fā)上舔庶,一...
    開封第一講書人閱讀 51,488評論 1 302
  • 那天,我揣著相機與錄音陈醒,去河邊找鬼惕橙。 笑死,一個胖子當著我的面吹牛钉跷,可吹牛的內(nèi)容都是我干的弥鹦。 我是一名探鬼主播,決...
    沈念sama閱讀 40,275評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼爷辙,長吁一口氣:“原來是場噩夢啊……” “哼彬坏!你這毒婦竟也來了?” 一聲冷哼從身側響起膝晾,我...
    開封第一講書人閱讀 39,176評論 0 276
  • 序言:老撾萬榮一對情侶失蹤栓始,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后血当,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體幻赚,經(jīng)...
    沈念sama閱讀 45,619評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡禀忆,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,819評論 3 336
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了落恼。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片箩退。...
    茶點故事閱讀 39,932評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖佳谦,靈堂內(nèi)的尸體忽然破棺而出戴涝,到底是詐尸還是另有隱情,我是刑警寧澤钻蔑,帶...
    沈念sama閱讀 35,655評論 5 346
  • 正文 年R本政府宣布啥刻,位于F島的核電站,受9級特大地震影響咪笑,放射性物質發(fā)生泄漏郑什。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,265評論 3 329
  • 文/蒙蒙 一蒲肋、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧钝满,春花似錦兜粘、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,871評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至碎捺,卻和暖如春路鹰,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背收厨。 一陣腳步聲響...
    開封第一講書人閱讀 32,994評論 1 269
  • 我被黑心中介騙來泰國打工晋柱, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人诵叁。 一個月前我還...
    沈念sama閱讀 48,095評論 3 370
  • 正文 我出身青樓雁竞,卻偏偏與公主長得像,于是被迫代替她去往敵國和親拧额。 傳聞我的和親對象是個殘疾皇子碑诉,可洞房花燭夜當晚...
    茶點故事閱讀 44,884評論 2 354