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: try:
with open("save.p", "rb") as f: with open("save.p", "rb") as f:
database = pickle.load(f) database = pickle.load(f)
print("Loaded", database)
except (FileNotFoundError) as e: except (FileNotFoundError) as e:
database = {'languages': [], database = {'languages': [],
'phonemes': [], 'phonemes': [],

View File

@ -1,4 +1,6 @@
var navSelect = "home"; 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]. var navi = [ // Array containing navigation items in form [Font-Awesome class name, Display Text, Onclick function].
["home", "Home", "home"], ["home", "Home", "home"],
@ -50,3 +52,25 @@ function updateNav(op) {
newNav.style.backgroundColor = "#F8F3F0"; newNav.style.backgroundColor = "#F8F3F0";
newNav.style.color = "#F47922"; 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> <!DOCTYPE html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1"> <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="{{ url_for('static', filename='velocity.min.js') }}"></script>
<script src="https://use.fontawesome.com/c8d5486cd8.js"></script> <script src="https://use.fontawesome.com/c8d5486cd8.js"></script>
</head> </head>
<body> <body>
<div id="header1" class="colorFade"> <div id="header1" class="colorFade">
<h1>/smirkär/</h1> <h1>/smirkär/</h1>
@ -55,4 +57,5 @@
</div> </div>
</body> </body>
<script src="{{ url_for('static', filename='index.js') }}"></script> <script src="{{ url_for('static', filename='index.js') }}"></script>
</html> </html>