Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

A port of djangos storages framework for use with flask applications

Project description

Quickstart
==========

.. include:: header.rst


**1** :ref:`Install Flask-Servatus <installation>` via pip
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sourcecode:: shell

$ pip install Flask-Servatus


**2** :ref:`Initialise <initialise>` and :ref:`configure <configuration>` the ``Servatus`` application object
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sourcecode:: python

from flask import Flask
from flask.ext.servatus import Servatus

app = Flask(__name__)
servatus = Servatus(app)

#.init_app() interface is also availble..

def factory(arg, arg2):

app = Flask(__name__)
servatus = Servatus()
servatus.init_app(app)

return app



**3** Use your prefered :ref:`storages <storages>` object to save files.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. sourcecode:: python

from flask import Flask
from flask.ext.servatus import Servatus
from flask.ext.servatus.files import ContentFile
from flask.ext.servatus.storages import get_default_storage

app = Flask(__name__)
servatus = Servatus(app)

storage = get_default_storage()

@app.route('/uploads', methods=['GET', 'POST'])
def handle_upload():
# handle uploaded file from user subitted form..

storage.save('foo.txt', request.files['file'])

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
flask_servatus-0.1.3.tar.gz (18.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page