Skip to content

Commit a58470a

Browse files
committed
Commit
1 parent ea09b7c commit a58470a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

File Upload - Web/Client/client.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import requests
2+
3+
url = "http://localhost:7410/"
4+
file_object = open('file_to_upload.txt', 'rb')
5+
header = {'Authorization': 'any_password'}
6+
files = {'file': file_object}
7+
try:
8+
r = requests.post(url, headers=header,files=files)
9+
print(r.text)
10+
finally:
11+
file_object.close()

File Upload - Web/Server/server.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from flask import *
2+
app = Flask(__name__)
3+
4+
5+
@app.route('/', methods = ['POST'])
6+
def success():
7+
headers = request.headers
8+
pwd = headers.get("Authorization")
9+
if request.method == 'POST' and pwd=='any_password':
10+
f = request.files['file']
11+
f.save(f.filename)
12+
return "success"
13+
else:
14+
return "Authentication Failed"
15+
16+
17+
if __name__ == '__main__':
18+
app.run(debug = True,host='0.0.0.0', port=7410)

0 commit comments

Comments
 (0)