我已經寫了一個角js演示代碼,我正在使用Bottle Python API進行UI路由。以下是控制器,工廠和python服務器代碼的代碼示例。在運行時,我得到500內部服務器錯誤。請幫助我找出錯誤。提前致謝。500(內部服務器錯誤)使用瓶Python和Angular JS
lax.py
import json,collections,os
import MySQLdb
#import paramiko
from bottle import run, route, template, static_file, request, redirect, get, post
@route('/assets/<filepath:path>')
def serve_static(filepath):
return static_file(filepath, root='static/')
@route('/')
def root():
return template('index.html')
# def connectSSH():
# ssh = paramiko.SSHClient()
# ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# ssh.load_system_host_keys()
# ssh.connect('10.200.8.215', username='root', password='qwer123')
# print 'success connect'
# connectSSH()
@route('/sshconnect', method='POST')
def sshConnect(data):
print data
def main():
run(host='0.0.0.0', port=7000, debug=True, reloader=True)
if __name__ == '__main__':
main()
jobCtrl.js
app.controller('jobCtrl', ['$scope', 'sshConnectionFactory', function($scope, sshConnectionFactory) {
$scope.serverList =[ {"serverName":"HP", "serverIPs":[ "10.98.67.5","10.678.98.54","10.456.76.9"]},
{"serverName":"DELL", "serverIPs":[ "10.98.67.5","10.678.98.54","10.456.76.9"]},
{"serverName":"WIPRO", "serverIPs":[ "10.200.8.14","10.200.8.215","10.456.76.9"]},
{"serverName":"CISCO", "serverIPs":[ "10.98.67.5","10.678.98.54","10.456.76.9"]}
]
$scope.packagePath = '/home/satyajit/main.yml';
$scope.populateServerIPs = function(selectedServerName) {
$scope.correspondingServerIPs = selectedServerName.serverIPs ;
}
$scope.selectedServer = function(selectedServerIP) {
console.log(selectedServerIP);
}
$scope.sshConnection = function(ip, username, password) {
console.log(ip, username, password);
var status = sshConnectionFactory.makeSSHConnection(ip, username, password);
}
}]);
sshConnectionFactory.js
app.factory('getTestcaseFactory', ['$http', '$routeParams', '$q', function($http, $routeParams, $q) {
return {
list: function() {
var deferred = $q.defer();
$http.get('/testcase/' + $routeParams.testcase)
.success(function(data, status, headers, config) {
deferred.resolve(data);
})
.error(function(data, status, headers, config) {
deferred.reject("Error fetching XML file: " + status + ' ' + JSON.stringify(headers));
});
return deferred.promise;
}
};
}]);
編輯:
堆棧跟蹤 -
POST http://localhost:7000/sshconnect 500 (Internal Server Error)(anonymous function) @ angular.js:9683sendReq @ angular.js:9487$get.serverRequest @ angular.js:9204processQueue @ angular.js:12984(anonymous function) @ angular.js:13000$get.Scope.$eval @ angular.js:14200$get.Scope.$digest @ angular.js:14016$get.Scope.$apply @ angular.js:14304(anonymous function) @ angular.js:22650eventHandler @ angular.js:2979
哪裏哦堆棧跟蹤在哪裏? – John
python有錯誤,而不是js。我們需要看到這一點。 – John
對不起!我添加了編輯。我希望它有幫助。 –