Skip to content
This repository was archived by the owner on May 31, 2019. It is now read-only.
Masashi SHIBATA edited this page Dec 5, 2016 · 1 revision

Usage

Basic Usage

Create main.py :

.. code-block:: python

def app(env, start_response): start_response('200 OK', [('Content-type', 'text/plain; charset=utf-8')]) return [b'Hello World']

Run this application using wsgiref:

.. code-block:: console

$ wsgicli run main.py app

Run this application in specified host(default: localhost) and port(default: 8000):

.. code-block:: console

$ wsgicli run main.py app -h 0.0.0.0 -p 8080

Static files

Run wsgi application and serve static files:

Create static/style.css:

.. code-block:: css

.container { max-width: 980px; }

And run:

.. code-block:: console

$ wsgicli run main.py app -p 8000 --static --staticroot static --staticdirs static/ $ curl http://localhost:8000/static/main.css .container { max-width: 980px; }

line profiler

Thanks to rkern/line_profiler <https://github.com/rkern/line_profiler>_ and ymyzk/wsgi_lineprof <https://github.com/ymyzk/wsgi_lineprof>_ :) Usage is like this:

.. code-block:: console

$ wsgicli run main.py app -p 8000 --lineprof Start: 127.0.0.1:8000

Time unit: 1e-06 [sec]

File: wsgi_lineprof_example.py Name: index Total time: 1.0027 [sec] Line Hits Time Code

   47                         @app.route('/')
   48                         def index():
   49         1      1002693      name = get_name()
   50         1            7      return "Hello, {}!!".format(name)

File: wsgi_lineprof_example.py Name: get_name Total time: 1.00267 [sec] Line Hits Time Code

   41                         def get_name():
   42                             # Get some data...
   43         1      1002670      time.sleep(1)
   44         1            3      return "Monty Python"

vmprof profiler

Still Not Implemented

Using vmprof and vmprof-server.

.. code-block:: console

$ wsgicli run main.py app -p 8000 --vsprof

refs: