上传文件至 ''

[](https://)
This commit is contained in:
mch 2023-04-19 13:59:04 +08:00
parent 6a6978bd5e
commit 08b6d444ce
5 changed files with 80 additions and 0 deletions

10
Storage.iml Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<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_hi('PyCharm')
# 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.10 (Storage)" 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/Storage.iml" filepath="$PROJECT_DIR$/.idea/Storage.iml" />
</modules>
</component>
</project>

39
test.py Normal file
View File

@ -0,0 +1,39 @@
from flask import Flask, request, send_file
from flask_restful import Resource, Api, reqparse
import os
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):
os.remove(object_name)
api.add_resource(ObjectStorage,'/objects/<string:object_name>')
@app.route("/")
def hello():
return "Hello World!"
@app.route("/1")
def hello2():
return "Hello aaaaa World!"
if __name__ == "__main__":
app.run()