python - Basic ToDo application issue with Flask+AngularJS -


for last 2 days i`m trying figure out how setup angularjs flask backend. have code init.py file

    1 flask import flask, render_template, jsonify, send_file, request   2 flask.ext.triangle import triangle   3    4 app = flask(__name__, static_path='/static')   5 triangle(app)   6 app.debug() = true   7    8 @app.route('/')   9 def homepage():  10     return render_template('home.html')  11   12 @app.route('/todo')  13 def todos():  14     return render_template('todo.html')  15   16 if __name__ == "__main__":  17     app.run() 

and basic todo application, working when try on computer. when upload server , try go /todo url 500 internal server error.

    <!doctype html> <html ng-app>  <head> </head>  <body>     <h2>todo</h2>     <div ng-controller="todoctrl">         <span>{{remaining()}} of {{todos.length|angular}} remaining</span> [ <a href="" ng-click="archive()">archive</a> ]         <ul class="unstyled">             <li ng-repeat="todo in todos">                 <input type="checkbox" ng-model="todo.done">                 <span class="done-{{todo.done|angular}}">{{todo.text|angular}}</span>             </li>         </ul>         <form ng-submit="addtodo()">             <input type="text" ng-model="todotext" size="30" placeholder="add new todo here">             <input class="btn-primary" type="submit" value="add">         </form>     </div>     <script>          function todoctrl($scope) {   $scope.todos = [     {text:'learn angular', done:true},     {text:'build angular app', done:false}];    $scope.addtodo = function() {     $scope.todos.push({text:$scope.todotext, done:false});     $scope.todotext = '';   };    $scope.remaining = function() {     var count = 0;     angular.foreach($scope.todos, function(todo) {       count += todo.done ? 0 : 1;     });     return count;   };    $scope.archive = function() {     var oldtodos = $scope.todos;     $scope.todos = [];     angular.foreach(oldtodos, function(todo) {       if (!todo.done) $scope.todos.push(todo);     });   }; }     </script>          <script src="{{ url_for('static', filename='/js/angular.js') }}"></script> </body> </html> 

any ideas how fix ? tried placing angular code in app.js in /static/js folder still not working

first run app in debug

app.run(debug=true) 

this should provide more info error

second iirc triangle requires pass angular filter angular template tags

<li ng-repeat="todo in todos">             <input type="checkbox" ng-model="todo.done">             <span class="done-{{todo.done|angular}}">{{todo.text|angular}}</span>         </li> 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -