2017-02-24 78 views
0

我有以下設置:Ajax調用內部工作,但不是外部

  • 的Windows Server 2016
  • 的Python 3.4
  • IIS 10
  • fastwcgi 2.2.0
  • 燒瓶 所以當地的一切工作得很好,但是當我從外部調用Web時,它會引發錯誤500,內部服務器錯誤。

我用runserver.py在本地運行網頁,一切似乎都很順利。我認爲這與某種終點有關。我會後我的代碼,如果必要的,但它是一個相當大的,但是這是整體結構:

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 //這個發送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."); 
     }); 

我認爲它更IIS問題,而不是蟒蛇/ JS SYNT的斧頭因爲當地一切都很好,但我可以根據需要提供更多信息。

+0

你能通過iis獲得燒瓶來返回一個視圖嗎? (例如'Hello,world'),還是你正在從不同的域調用'/ generate'? – scomes

+0

是的,它返回視圖罰款。你可以看看網頁,如果你喜歡/刪除/ – Gio

+0

http://stackoverflow.com/questions/18059937/flask-app-raises-a-500-error-with-no-exception嘗試獲取異常傳播,以便我們可以看到堆棧跟蹤 – scomes

回答

0

我弄明白了。它看起來像它正在尋找的資源不在搜索路徑中。

我添加了一個嘗試/除了在整個功能,並給了我確切的錯誤。

我仍然不知道如何讓燒瓶顯示詳細的錯誤(試過debug = true,propagate = true),但問題已修復。謝謝你的幫助!

相關問題