working post on js
This commit is contained in:
parent
b6c87fa506
commit
6b9df945d3
@ -151,7 +151,6 @@ def backend():
|
|||||||
for phoneme, value in recieved['phonemes'].items():
|
for phoneme, value in recieved['phonemes'].items():
|
||||||
with db.session.no_autoflush:
|
with db.session.no_autoflush:
|
||||||
search = Phoneme.query.filter_by(name=phoneme).first()
|
search = Phoneme.query.filter_by(name=phoneme).first()
|
||||||
print(search)
|
|
||||||
if not search:
|
if not search:
|
||||||
search = Phoneme(name=phoneme)
|
search = Phoneme(name=phoneme)
|
||||||
db.session.add(search)
|
db.session.add(search)
|
||||||
@ -173,17 +172,20 @@ def backend():
|
|||||||
# Manipulate Updates
|
# Manipulate Updates
|
||||||
@app.route("/updates", methods=["GET", "POST", "PATCH"])
|
@app.route("/updates", methods=["GET", "POST", "PATCH"])
|
||||||
def updates():
|
def updates():
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
recieved = request.get_json()
|
recieved = request.get_json()
|
||||||
update = Update(author=recieved['author'],
|
update = Update(author=recieved['author'],
|
||||||
title=recieved['title'],
|
title=recieved['title'],
|
||||||
content=recieved['content'])
|
content=recieved['content'])
|
||||||
db.session.add(update)
|
db.session.add(update)
|
||||||
|
|
||||||
elif request.method == "PATCH":
|
elif request.method == "PATCH":
|
||||||
update = Update.query.filter_by(id=recieved['id']).first()
|
update = Update.query.filter_by(id=recieved['id']).first()
|
||||||
update.name = recieved['author']
|
update.name = recieved['author']
|
||||||
update.title = recieved['title']
|
update.title = recieved['title']
|
||||||
update.content = recieved['content']
|
update.content = recieved['content']
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return jsonify([{"author": update.name,
|
return jsonify([{"author": update.name,
|
||||||
"id": update.id,
|
"id": update.id,
|
||||||
@ -192,5 +194,6 @@ def updates():
|
|||||||
"date": update.date}
|
"date": update.date}
|
||||||
for update in Update.query.all()])
|
for update in Update.query.all()])
|
||||||
|
|
||||||
# if __name__ == "__main__":
|
|
||||||
# app.run(host="0.0.0.0")
|
if __name__ == "__main__":
|
||||||
|
app.run(host="0.0.0.0")
|
||||||
|
|||||||
@ -22,6 +22,28 @@ var dropOp = {
|
|||||||
|
|
||||||
var dropOpStore = {};
|
var dropOpStore = {};
|
||||||
|
|
||||||
|
// Left This so that the post function can be reused
|
||||||
|
|
||||||
|
// function temporary(data) {
|
||||||
|
// for(var i = 0; i < data.length; i++) {
|
||||||
|
// $.ajax({
|
||||||
|
// url: serverURL + '/server',
|
||||||
|
// type: 'POST',
|
||||||
|
// data: JSON.stringify(data[i]),
|
||||||
|
// dataType: "json",
|
||||||
|
// contentType: 'application/json;charset=UTF-8'
|
||||||
|
// })
|
||||||
|
// .then(
|
||||||
|
// function success(data) {
|
||||||
|
// console.log(data);
|
||||||
|
// },
|
||||||
|
// function error(e) {
|
||||||
|
// console.log(e);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
function createNav() {
|
function createNav() {
|
||||||
for (var i = 0; i < navi.length; i++) { // Create navigation tabs.
|
for (var i = 0; i < navi.length; i++) { // Create navigation tabs.
|
||||||
var side = document.getElementById("sidebar");
|
var side = document.getElementById("sidebar");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user