0

I have the following setup:

  • Windows Server 2016
  • Python 3.4
  • IIS 10
  • fastwcgi 2.2.0
  • flask So locally everything works just fine, but when i call the web from external, it throws error 500, internal server error.

I ran the web locally with runserver.py and everything seemed to go good. Im thinking this is somehow related to the endpoints of some sort. I will post my code if necessary but its a pretty large but this is overall structure:

app.py:

@app.route('/generate', methods=['GET', 'POST'])
def generate():
     if  request.method == "POST":
        txt = request.json['text']
     returnedQuestions,returnAnswers, returnSources = QG.s(txt)
     return  json.dumps({'Questions': returnedQuestions, 'Answers':returnAnswers, 'Sources':returnSources})

QG.s(inputRequest):

INPA = []
INPQ = []
INPS = []
#do work with inputRequest
return INPA, INPQ, INPS

menu.js //this sends the POST

var userInputData = { 'text': '' }
        userInputData['text'] = $("#input").val();
        $.ajax({
            url: '/generate',
            type: 'POST',
            async: false,
            data: JSON.stringify(userInputData),
            contentType: 'application/json;charset=UTF-8',
        }).done(function (o) {
            var result = JSON.parse(o);
            returnedQuestion = (result.Questions);
            returnedAnswer = (result.Answers);
            returnedSource = (result.Sources);
            document.getElementById('CreateButton').className = "button";
        }).error(function (e) {
            debugger;
            window.alert("Error occured. Try Again.");
        });

I think its more of IIS issue rather than python/JS syntax because locally everything is fine, but i can provide more info as needed.

scorpion5211
  • 1,020
  • 2
  • 13
  • 33
  • Have you been able to get flask to return a view via iis? (eg a 'Hello, world' ), or are you making the call to '/generate' from a different domain? – scomes Feb 24 '17 at 20:14
  • yes, it returns views fine. you may look at the web if you like /deleted/ – scorpion5211 Feb 24 '17 at 20:16
  • http://stackoverflow.com/questions/18059937/flask-app-raises-a-500-error-with-no-exception try getting the exception to propagate so that we can see the stack trace – scomes Feb 24 '17 at 20:23
  • i turned the propagate on not sure how this will help, the error is still broad. app.config['PROPAGATE_EXCEPTIONS'] = True – scorpion5211 Feb 24 '17 at 20:50

1 Answers1

0

I got this figured out. It looked like the resource it was looking for was not in the search path.

I added a try/except in the whole function and gave me exact error.

I still dont know how to make flask display the detailed error (tried debug = true, propagate = true) but issue is fixed. Thank you scomes for the help!

scorpion5211
  • 1,020
  • 2
  • 13
  • 33