from flask import Flask, jsonify, request
import jedi

app = Flask( __name__ )


@app.route( '/healthy' )
def healthy():
    return jsonify()


@app.route( '/ready' )
def ready():
    return jsonify()


@app.route( '/completions', methods=['POST'] )
def completion():
    script = _GetJediScript( request.get_json() )
    return jsonify( {
        'completions': [
            {
                'name':        completion.name,
                'description': completion.description,
                'docstring':   completion.docstring()
            } for completion in script.completions() ]
        } )


def _GetJediScript( request_data ):
    filename = request_data[ 'filepath' ]
    contents = request_data[ 'contents' ]
    line     = request_data[ 'line_num' ]
    column   = request_data[ 'column_num' ]

    return jedi.Script( contents, line, column, filename )

@@ -1,8 +1,295 @@
+import os%0Aimport sys%0A%0Athird_party_dir = os.path.join( os.path.dirname( __file__ ), 'third_party' )%0Afor folder in os.listdir( third_party_dir ):%0A    sys.path.insert( 0, os.path.realpath( os.path.join( third_party_dir,%0A                                                        folder ) ) )%0A%0A
 from fla
@@ -335,16 +335,17 @@
 t jedi%0A%0A
+%0A
 app = Fl

Use vendored library