title: Can't use Jsonify in Flask websocket
body: <p>Jsonify doesn't seem to work outside of an application context, is there a workaround?</p>
  
  <p>I am replacing some ajax requests with websockets because it is needed for performances and network issues. I installed Flask-WebSocket with pip in my env.  Now I get an error:</p>
  
  <pre><code>RuntimeError: working outside of application context
  </code></pre>
  
  <p>The skeleton of my application is as follows:</p>
  
  <pre><code>app/
  ├── forms
  ├── static
  │   ├── css
  │   ├── img
  │   │   └── DefaultIcon
  │   │       ├── eps
  │   │       └── png
  │   └── js
  ├── templates
  ├── ups
  └── views
  </code></pre>
  
  <p>The websockets python files are located in views/ajax.py:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  # OS Imports
  import time
  
  # Flask Imports
  from flask import jsonify
  from .. import sockets
  from app.functions import get_cpu_load, get_disk_usage, get_vmem
  
  # Local Imports
  from app import app
  from app.views.constants import info, globalsettings
  
  @sockets.route('/_system')
  def _system(ws):
      """
      Returns the system informations, JSON Format
      CPU, RAM, and Disk Usage
      """
      while True:
          message = ws.receive()
          if message == "update":
              cpu = round(get_cpu_load())
              ram = round(get_vmem())
              disk = round(get_disk_usage())
              ws.send(jsonify(cpu=cpu, ram=ram, disk=disk)
  </code></pre>
  
  <p>I launch my application using this command:</p>
  
  <pre><code>gunicorn -k flask_sockets.worker app:app
  </code></pre>
  
  <p>Here is my <code>__init__.py</code> in app/ folder :</p>
  
  <pre><code># -*- coding: utf-8 -*-
  from flask import Flask
  from flask_sockets import Sockets
  
  app = Flask(__name__)
  sockets = Sockets(app)
  app.config.from_object('config')
  from app import views as application
  </code></pre>
  
  <p>Why doesn't jsonify work, what can I use instead?</p>