Skip to content

Commit 2d9a696

Browse files
committed
init new
1 parent 6d24da8 commit 2d9a696

File tree

7 files changed

+38
-0
lines changed

7 files changed

+38
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

media-files/api.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from flask import Flask, request
2+
3+
app = Flask(__name__)
4+
app.secret_key = 'Superrandom'
5+
6+
@app.route('/test-connection',methods=['GET','POST'])
7+
def func():
8+
return "OK",200
9+
10+
@app.route('/test-file',methods=['GET','POST'])
11+
def file():
12+
a = request.files['media']
13+
# a.save('test.jpg')
14+
15+
16+
print(a)
17+
a.save('./store/'+a.filename)
18+
19+
# f = open("test.jpg", 'wb')
20+
# f.write(a.read())
21+
# f.close()
22+
a.close()
23+
return "OK",200
24+
25+
26+
27+
28+
if __name__ == "__main__":
29+
app.run(host="0.0.0.0")

media-files/client.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import requests
2+
3+
url = "http://localhost:5000/test-file"
4+
5+
file = {"media": open('dog.jpg', 'rb')}
6+
7+
r = requests.post(url, files=file)
8+
9+
print(r)

media-files/dog.jpg

160 KB
Loading

media-files/store/dog.jpg

160 KB
Loading

media-files/t.jpg

160 KB
Loading

media-files/test.jpg

160 KB
Loading

0 commit comments

Comments
 (0)