1

enter image description here

I am creating an API for my machine learning Model using Flasgger and Flask in python.

After running my API file I am getting the below error as ‘Failed to load API documents. Fetch error Internal Server Error/ apispex_1.json

Below is my code :

import pickle
from flask import Flask, abort, jsonify, request
import numpy as np
import pandas as pd
from flasgger import Swagger 

with open('./im.pkl', 'rb') as model_file:
    model = pickle.load(model_file)

app = Flask(__name__)
swagger = Swagger(app)

@app.route('/predict')
def predict1():
 """Example
    ---
    parameters:
        -name: Days
         in: query
         type= number
         required: true
         --
         --
         --
   """
 Days = request.args.json('Days')
prediction = model.predict(np.array([[Days]]))
return str(prediction)

if __name__ == '__main__':
    app.run(port=5000, debug=True)
Aditya Sharma
  • 147
  • 1
  • 10

1 Answers1

0

You got an error in docstring description:

@app.route('/predict')
def predict1():
 """Example
    ---
    parameters:
        - name: Days
          in: query
          type: integer
          required: true
   """

Just replace type= number to type: integer

Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102