|
from flask import Flask, request |
|
from flask_restful import Resource, Api, reqparse |
|
from flask_cors import CORS |
|
from encoder_file import get_encoder |
|
|
|
encoder = get_encoder() |
|
app = Flask(__name__) |
|
CORS(app) |
|
api = Api(app) |
|
parser = reqparse.RequestParser() |
|
|
|
class Status(Resource): |
|
def get(self): |
|
return {'status': 'Server Running Successfully'} |
|
|
|
|
|
DATASET_CONSTANT = { |
|
"data": [ |
|
"dataset-1", |
|
"dataset-2", |
|
"dataset-3", |
|
"dataset-4", |
|
"dataset-5" |
|
] |
|
} |
|
|
|
class Data(Resource): |
|
def get(self): |
|
return DATASET_CONSTANT |
|
|
|
api.add_resource(Status, '/') |
|
api.add_resource(Data, '/data') |
|
|
|
|
|
@app.route('/get_sample',methods=['POST']) |
|
def _inference(): |
|
|
|
try: |
|
info = request.json["data"] |
|
return jsonify({"result" : encoder.encode(info)}) |
|
|
|
except Exception as e: |
|
print(e) |
|
return jsonify({"result":"-1"}) |
|
|
|
@app.route('/checking',methods=['GET']) |
|
def check(): |
|
return jsonify({"status": 'working'}) |
|
|
|
if __name__ == '__main__': |
|
app.run(debug=True) |