File tree 2 files changed +29
-0
lines changed
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
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 ()
Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments