diff --git a/flaskProject1/.idea/.gitignore b/flaskProject1/.idea/.gitignore new file mode 100644 index 0000000..4aa91ea --- /dev/null +++ b/flaskProject1/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/flaskProject1/.idea/flaskProject1.iml b/flaskProject1/.idea/flaskProject1.iml new file mode 100644 index 0000000..2484ca0 --- /dev/null +++ b/flaskProject1/.idea/flaskProject1.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/flaskProject1/.idea/inspectionProfiles/Project_Default.xml b/flaskProject1/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..375bf5e --- /dev/null +++ b/flaskProject1/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/flaskProject1/.idea/inspectionProfiles/profiles_settings.xml b/flaskProject1/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/flaskProject1/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/flaskProject1/.idea/misc.xml b/flaskProject1/.idea/misc.xml new file mode 100644 index 0000000..b534b89 --- /dev/null +++ b/flaskProject1/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/flaskProject1/.idea/modules.xml b/flaskProject1/.idea/modules.xml new file mode 100644 index 0000000..f116556 --- /dev/null +++ b/flaskProject1/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/flaskProject1/__pycache__/app.cpython-38.pyc b/flaskProject1/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000..d395a69 Binary files /dev/null and b/flaskProject1/__pycache__/app.cpython-38.pyc differ diff --git a/flaskProject1/app.py b/flaskProject1/app.py new file mode 100644 index 0000000..b4bb574 --- /dev/null +++ b/flaskProject1/app.py @@ -0,0 +1,34 @@ +import os + +from flask import Flask, request, send_file +from flask_restful import Resource, Api, reqparse + +app = Flask(__name__) +api = Api(app) + +class ObjectStorage(Resource): + + # @app.route('/objects/', methods=['GET', 'POST', 'PUT']) + def put(self, object_name): + file = request.files['file'] + file.save(object_name) + return {'status': 'success'} + + # @app.route('/objects/', methods=['GET', 'POST', 'PUT']) + def get(self, object_name): + file = open(object_name, 'rb') + return send_file(file, mimetype='application/octet-stream') + + # @app.route('/objects/', methods=['GET', 'POST', 'PUT']) + def delete(self, object_name): + os.remove(object_name) + return {'status': 'success'} + +@app.route('/') +def hello_world(): # put application's code here + return 'Hello World!' + +api.add_resource(ObjectStorage, '/objects/') + +if __name__ == '__main__': + app.run()