Last active
June 1, 2023 11:14
-
-
Save jstacoder/863a5df5d7bb76c88323 to your computer and use it in GitHub Desktop.
flask / angular example (underscores in filenames mean directorys)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask import render_template | |
app = Flask(__name__) | |
app.url_map.strict_slashes = False | |
@app.route('/partials/<partial>') | |
def partial(partial): | |
return render_template(partial,jinja_var='this is from jinja') | |
@app.route('/') | |
def index(): | |
return render_template('index.html') | |
if __name__ == "__main__": | |
app.run(debug=True,port=5555,host='0.0.0.0') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var app = angular.module('flaskApp',['ngRoute']) | |
.controller('IndexController',[function(){ | |
var self = this; | |
self.message = {}; | |
self.message.text = 'This is from angular!!!'; | |
}]) | |
.config(['$httpProvider','$routeProvider', '$locationProvider', | |
function($httpProvider, $routeProvider, $locationProvider) { | |
$routeProvider | |
.when('/', { | |
templateUrl: 'partials/landing.html', | |
controller: 'IndexController', | |
controllerAs:'ctrl' | |
}) | |
.otherwise({ | |
redirectTo: '/' | |
}); | |
$locationProvider.html5Mode(true); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html ng-app="flaskApp"> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.10/angular.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.10/angular-route.js"></script> | |
<script src="{{ url_for('static',filename="js/app.js")}}"></script> | |
<base href="/" /> | |
</head> | |
<body ng-view> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% raw %} | |
{{ ctrl.message.text }} | |
{% endraw %} | |
{{ jinja_var }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment