Skip to main content

Provides MIME type based request dispatching mechanism.

Project description

Flask-Mime is Flask extension that enables applications to dispatch requests based on Accept header of it.


Install the extension with the following command:

$ pip install Flask-Mime


Create a Mime object and define routes with MIME types:

from flask import Flask, render_template, jsonify
from flask_mime import Mime

app = Flask(__name__)
mimetype = Mime(app)

def index_html():
    return render_template('index.html')

def index_json():
    return jsonify(data={'content': 'index'})

Each requests are dispatched depending on the value of Accept header, even though they have same request path:

client = app.test_client()
client.get('/', headers={'Accept': 'text/html'})  # returns html
client.get('/', headers={'Accept': 'application/json'})  # returns json


Note that MIME type based request dispatching mechanism may have negative influence for some applications, for example, which has a cache system.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Flask-Mime, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size Flask-Mime-0.1.0.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View
Filename, size (10.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page