Skip to main content

flask-command - Run you flask+gunicorn app as a command

Project description

flask-command is a simple tool that allows you to call your flask application from the command line after wrapping through gunicorn. This is useful if you’d like to create a console_script entry point for your flask application.

Intended Use Case

Let’s assume your project is called myproject. A flask app exists or is accessible from myproject/__init__.py. The following shows how you’d use flask-command.

In a file called myproject/main.py:

from flaskcommand import flask_command
from myproject import app

main = flask_command(app)

In your setup.py file:

setup(name='myproject',
    version='0.0.1',
    description="myproject - is awesome",
    long_description="myproject - is really awesome",
    keywords='',
    author='Reuven V. Gonzales',
    author_email='reuven@tobetter.us',
    packages=['myproject'],
    include_package_data=True,
    zip_safe=False,
    install_requires=[
        'flask-command',
        'flask',
    ],
    entry_points={
        'console_scripts': [
            # WITH FLASK-COMMAND YOU CAN
            # DEFINE YOUR SCRIPT HERE :-)
            'myproject-web = myproject.main:main',
        ]
    },
    classifiers=[
        'License :: OSI Approved :: MIT License',
        'Intended Audience :: Developers',
        'Programming Language :: Python',
        'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
    ],
)

Now, after installing your project you can start your flask server like this:

$ myproject-web -b 127.0.0.1:8000 -w 4 some_config_path

At this time specifying a path to a configuration file is required, but this probably won’t be so in the future.

Project details


Download files

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

Source Distribution

flask-command-0.0.2.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file flask-command-0.0.2.tar.gz.

File metadata

File hashes

Hashes for flask-command-0.0.2.tar.gz
Algorithm Hash digest
SHA256 73d1123bed5c931cfa28ec396a071dadb3c2c1a8e42c0bfc9e44668e0ed1d01c
MD5 c863b09958aafa4102920cabbd675100
BLAKE2b-256 f60b4bda37204956967085752da9d0d10511559044decea341cacadd0454c0ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page