上传文件至 ''

This commit is contained in:
ljh 2023-04-23 09:29:49 +08:00
parent df42f3ae08
commit bfb948b8be
5 changed files with 64 additions and 0 deletions

25
2.1.py Normal file
View File

@ -0,0 +1,25 @@
from flask import Flask,request,send_file
from flask_restful import Resource,Api,reqparse
app = Flask(__name__)
api=Api(app)
app=Flask(__name__)
api=Api(app)
class ObjectStorage(Resource):
def put(self,object_name):
file = request.files['file']
file.save(object_name)
return {'status':'success'}
def get(self,object_name):
file = open(object_name,'rb')
return send_file(file,mimetype='application/octet-stream')
def delete(self,object_name):
pass
api.add_resource(ObjectStorage,'/objects/<string:object_name>')
if __name__=="__main__":
app.run()

8
2.iml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

16
main.py Normal file
View File

@ -0,0 +1,16 @@
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def print_hi(name):
# Use a breakpoint in the code line below to debug your script.
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
print("hello world")
# See PyCharm help at https://www.jetbrains.com/help/pycharm/

7
misc.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (9.24) (3)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>

8
modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/2.iml" filepath="$PROJECT_DIR$/.idea/2.iml" />
</modules>
</component>
</project>