Commit bcb8c119 authored by Bucky Lee's avatar Bucky Lee
Browse files

update

parent aa004018
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line


node_modules
**/node_modules

*.log
**/.DS_Store
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/models" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="jdk" jdkName="Conda Python 3.9 " jdkType="Python SDK" />
    <orderEntry type="sourceFolder" forTests="false" />
  </component>
  <component name="TemplatesService">
+1 −1
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
  <component name="ProjectRootManager" version="2" project-jdk-name="Conda Python 3.9 " project-jdk-type="Python SDK" />
</project>
 No newline at end of file
+2.41 KiB

File added.

No diff preview for this file type.

+27 −5
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import os
import core.main

UPLOAD_FOLDER = r'./uploads'
ALLOWED_EXTENSIONS = set(['dcm'])
ALLOWED_EXTENSIONS = {'png', 'tiff'}

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
@@ -32,6 +32,7 @@ def hello_world():
def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS


@app.route('/upload', methods=['GET', 'POST'])
def upload_file():
    file = request.files['file']
@@ -52,11 +53,32 @@ def upload_file():
    return jsonify({'status': 0})


@app.route("/download", methods=['GET'])
def download_file():
# show photo
@app.route('/tmp/<path:file>', methods=['GET'])
def show_photo(file):
    # print(file)
    if file is None:
        app.logger.info('file is None')
        abort(401)
    else:
        try:
            with open(f'tmp/{file}', "rb") as f:
                image_data = f.read()
            response = make_response(image_data)
            response.headers['Content-Type'] = 'image/png'
            return response
        except:
            app.logger.info('Exception!')
            abort(401)


@app.route("/download/<path:file>", methods=['GET'])
def download_file(file):
    # 需要知道2个参数, 第1个参数是本地目录的path, 第2个参数是文件名(带扩展名)
    return send_from_directory('data', 'testfile.zip', as_attachment=True)
    return send_from_directory('data', file, as_attachment=True)


if __name__ == '__main__':
    app.run()
    # with app.app_context():
    #     current_app.model = init_model()
    app.run(host='127.0.0.1', port=5003, debug=True)
Loading