From f50f553817b7cb50b30cb4bd5c51e4bc490604cf Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Wed, 20 Mar 2013 17:03:25 +0100 Subject: [PATCH] Renamed html to static, phase #2. --- src/main.py | 8 ++++++-- src/static/js/accounts.js | 6 +++--- src/static/js/entries.js | 6 +++--- src/static/js/months.js | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main.py b/src/main.py index 9d46cda..ffb4ac9 100644 --- a/src/main.py +++ b/src/main.py @@ -16,11 +16,15 @@ """ from app import app -from static import * - from api.controller.entries import * from api.controller.accounts import * +from flask import url_for, redirect + +@app.route('/') +def index(): + return redirect(url_for('.static', filename='index.html')) + if __name__ == '__main__': app.run(debug=True) diff --git a/src/static/js/accounts.js b/src/static/js/accounts.js index 62db844..978ef08 100644 --- a/src/static/js/accounts.js +++ b/src/static/js/accounts.js @@ -86,7 +86,7 @@ var AccountController = function($scope, $http, $rootScope) { $scope.saveAccount = function(account, modalScope) { // Ajax call to save the entry. var type; - var url = "api/accounts"; + var url = "/api/accounts"; if(account.id) { url += "/" + account.id; @@ -109,7 +109,7 @@ var AccountController = function($scope, $http, $rootScope) { // Function to remove of an entry. $scope.accountRemove = function(account, modalScope) { - $http.delete("api/accounts/" + account.id).success(function (data) { + $http.delete("/api/accounts/" + account.id).success(function (data) { message("success", "Save", data); // Reload accounts to update solds. @@ -123,7 +123,7 @@ var AccountController = function($scope, $http, $rootScope) { // Function to load accounts $scope.loadAccounts = function() { - $http.get("api/accounts").success($scope.loadAccounts_success); + $http.get("/api/accounts").success($scope.loadAccounts_success); }; $scope.loadAccounts_success = function (data) { diff --git a/src/static/js/entries.js b/src/static/js/entries.js index bc57c83..ead4b00 100644 --- a/src/static/js/entries.js +++ b/src/static/js/entries.js @@ -89,7 +89,7 @@ var EntryController = function($scope, $http, $rootScope, $filter) { $scope.savedItem = null; if(account && month) { - $http.get("api/entries/" + account.id + "/" + month.year + "/" + month.month).success($scope.loadEntries_success); + $http.get("/api/entries/" + account.id + "/" + month.year + "/" + month.month).success($scope.loadEntries_success); } else { $scope.loadEntries_success(null); } @@ -245,7 +245,7 @@ var EntryController = function($scope, $http, $rootScope, $filter) { // Prepare the Ajax call to save the entry. var type; - var url = "api/entries"; + var url = "/api/entries"; if(!$scope.isNew(entry)) { url += "/" + entry.id; @@ -266,7 +266,7 @@ var EntryController = function($scope, $http, $rootScope, $filter) { $scope.removeEntry = function(entry, modalScope) { // Cancel current editing. if (!$scope.isNew(entry)) { - $http.delete("api/entries/" + entry.id).success(function (result) { + $http.delete("/api/entries/" + entry.id).success(function (result) { message("success", "Delete", result); // Send the "entry removed" event. diff --git a/src/static/js/months.js b/src/static/js/months.js index babf277..d655062 100644 --- a/src/static/js/months.js +++ b/src/static/js/months.js @@ -40,7 +40,7 @@ var MonthController = function($scope, $http, $rootScope) { } if($scope.account) { - $http.get("api/accounts/" + $scope.account.id + "/months").success($scope.loadMonths_success); + $http.get("/api/accounts/" + $scope.account.id + "/months").success($scope.loadMonths_success); } else { $scope.$emit("monthsLoadedEvent", {account: null, month: null}); }