-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpost_php.py
More file actions
37 lines (29 loc) · 1.14 KB
/
post_php.py
File metadata and controls
37 lines (29 loc) · 1.14 KB
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
import requests
import base64
class PostPHP:
def __init__(self, id, name, exp, city, languages):
self.id = id
self.name = name
self.exp = exp
self.city = city
self.languages = languages
self.npy = "npy/face_" + str(id) + ".npy"
self.img = "png/face_" + str(id) + ".png"
def b64(self, filelocation):
with open(filelocation, "rb") as image_file:
encoded_string = base64.b64encode(image_file.read())
return encoded_string
def post(self):
url = "http://35.154.83.186/guideme/add_guide.php"
r = requests.post(url, data={'id': self.id,
'name': self.name,
'exp': self.exp,
'city':self.city,
'languages':self.languages,
'npy' : self.b64(self.npy),
'png' : self.b64(self.img)})
print (r.status_code)
print (r.text)
if __name__ == '__main__':
p = PostPHP(100, "Yash", "6", "Ahmedabad", "Hindi,English")
p.post()