added get method and language()

This commit is contained in:
Yaman Qalieh 2018-01-20 22:34:39 -05:00
parent ee25012598
commit 4c8fcc4eb1
3 changed files with 123 additions and 95 deletions

View File

@ -12,6 +12,7 @@ app.config.update(
try:
with open("save.p", "rb") as f:
database = pickle.load(f)
print("Loaded", database)
except (FileNotFoundError) as e:
database = {'languages': [],
'phonemes': [],

View File

@ -1,4 +1,6 @@
var navSelect = "home";
var serverURL = "http://0.0.0.0:5000";
var data;
var navi = [ // Array containing navigation items in form [Font-Awesome class name, Display Text, Onclick function].
["home", "Home", "home"],
@ -50,3 +52,25 @@ function updateNav(op) {
newNav.style.backgroundColor = "#F8F3F0";
newNav.style.color = "#F47922";
}
function getData() {
$.ajax({
url: serverURL + '/server',
type: 'GET'
})
.then(
function success(incoming) {
data = incoming;
},
function error(e) {
console.log(e);
}
);
console.log(data);
}
function language(language) {
return data.languages.filter(function(element) {
return element.name === language;
});
}

View File

@ -1,4 +1,5 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
@ -11,6 +12,7 @@
<script src="{{ url_for('static', filename='velocity.min.js') }}"></script>
<script src="https://use.fontawesome.com/c8d5486cd8.js"></script>
</head>
<body>
<div id="header1" class="colorFade">
<h1>/smirkär/</h1>
@ -55,4 +57,5 @@
</div>
</body>
<script src="{{ url_for('static', filename='index.js') }}"></script>
</html>