Skip to content
Snippets Groups Projects
Commit 51b17bb0 authored by Matias Nordli's avatar Matias Nordli
Browse files

/pick_up_shipment request complete

parent 30bbe153
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,7 @@ app.config['MYSQL_DB']="ski_equipment_factory"
mysql = MySQL(app)
#Transporter function, work in progress
@app.route('/get_shipment_status_info',methods=['GET'])
@app.route('/get_shipment_state',methods=['GET'])
def get_shipment_ready():
if request.method == 'GET':
......@@ -28,6 +28,28 @@ def get_shipment_ready():
cur.close()
return jsonify(shipment_ready),200
#Change shipment state to 'picked up'
@app.route('/pick_up_shipment',methods=['PUT'])
def pick_up_shipment():
if request.method == 'PUT':
data = request.get_json()
shipment_number = data['shipment_number']
cur=mysql.connection.cursor()
pickUp=cur.execute("UPDATE `shipment` SET state='picked up' WHERE shipment_number=%s",(shipment_number,))
mysql.connection.commit()
if pickUp > 0:
pickUp = cur.fetchall()
else:
return jsonify("No shipments matching requested number or shipment is already picked up."),404
order=cur.execute("SELECT * FROM `shipment` WHERE `shipment_number`=%s",(shipment_number,))
order=cur.fetchall()
cur.close()
return jsonify(order),200
if __name__ == '__main__':
app.run(debug=True)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment