Sorry for the late reply. Try adding: import sys,os sys.path.append(os.getcwd())
On Fri, Dec 13, 2019 at 11:53 PM Hema malini <nhemamalin...@gmail.com> wrote: > Hi, > > I am not sure whether i am facing an issue or it's a bug . I try to deploy > the sample Maas script in metron it works perfectly. In the model > collateral , now i add another python class which loads the trained model > pkl filed. I gave the absolute path as well as relative path( using dir > path). I want to import that python class to the flask code. when i submit > it starts with connection closed out . > > So it's not possible to load or import any other python class.Does model > collateral should only have one rest and one python file? > > from flask import Flask > from flask import request,jsonify > import socket > From Sample import sampleclass > app = Flask(__name__) > @app.route("/apply", methods=['GET']) > def predict(): > h = request.args.get('host') > r = {} > if h == 'yahoo.com' or h == 'amazon.com': > r['is_malicious'] = 'legit' > else: > r['is_malicious'] = 'malicious' > return jsonify(r) > > > In the above code i couldn't import the sample class though it is present > in the same folder. > > Thanks and Regards, > Hema > >