Commit 6a75cbd1 authored by Bucky Lee's avatar Bucky Lee
Browse files

feat: update content and controller

parent 08289873
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -6,14 +6,16 @@ import numpy as np
import shutil
import os
import core.main
from time import sleep

UPLOAD_FOLDER = r'data/unprocessed'
UPLOAD_FOLDER = os.path.join('data', 'unprocessed')
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'tiff'}

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER



# 添加header解决跨域
@app.after_request
def after_request(response):
@@ -36,17 +38,30 @@ def allowed_file(filename):
@app.route('/upload/<model_name>', methods=['GET', 'POST'])
def upload_file(model_name):
    file = request.files['file']
    print(datetime.datetime.now(), file.filename)
    # print(datetime.datetime.now(), file.filename)
    # print(os.path.splitext(file.filename)[1])
    msg = ''
    if file and allowed_file(file.filename):
        src_path = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
        file_id = find_next()
        file_name = str(file_id) + os.path.splitext(file.filename)[1]
        src_path = os.path.join(app.config['UPLOAD_FOLDER'], file_name)
        file.save(src_path)
        shutil.copy(src_path, 'data/processed')
        # msg = core.main.process(src_path, model_name)
        # if msg == 'Success':
        return 'Success!'
        return jsonify({'id':file_name})
    app.logger.info("Failed to deal with image!\n", msg)
    return 'Failed!'
    return jsonify({'id':file_name})

def find_next():
    file_list = os.listdir(UPLOAD_FOLDER)
    max = -1
    for f in file_list:
        if not f.startswith('.'):
            id = int(os.path.splitext(f)[0])
            if id > max:
                max = id
    return max + 1


# show photo
−50.6 KiB
Loading image diff...
−50.6 KiB
Loading image diff...
+2 −1
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@
}

.instruction {
  width: 60%;
  width: 50%;
  height: 45%;
  margin-top: 50%;
  margin-left: 15%;
}
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ declare module '@vue/runtime-core' {
    Image_upload: typeof import('./components/image_upload.vue')['default']
    Info: typeof import('./components/info.vue')['default']
    Instruction: typeof import('./components/instruction.vue')['default']
    Loading: typeof import('element-plus/es')['ElLoadingDirective']
    Record: typeof import('./components/Record.vue')['default']
    RouterLink: typeof import('vue-router')['RouterLink']
    RouterView: typeof import('vue-router')['RouterView']
Loading