-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shipment.py
38 lines (32 loc) · 869 Bytes
/
Shipment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#EAI
#Developing API - Python side - Shipment module
from flask import Flask
from flask import request,jsonify
from flask_cors import CORS
import mysql.connector
import requests
mydb = mysql.connector.connect(
host="localhost",
user="youruser",
password="yourpassword",
database="eaiCourier"
)
app=Flask(__name__)
CORS(app)
@app.route("/",methods=['POST'])
def T():
data = request.get_json()
print(data)
try:
mycursor = mydb.cursor()
sql = "INSERT INTO shipmentCourier (pickupAddress,DeliverAddress) VALUES (%s,%s)"
val = (data['PickupLocation'],data['DeliveryLocation'])
mycursor.execute(sql, val)
cus_id = mycursor.lastrowid
mydb.commit()
mycursor.close()
status="success"
except Exception:
status="some error occured"
return jsonify(status),200
app.run()