python类FileStorage()的实例源码

routes.py 文件源码 项目:chalupas 作者: Antojitos 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def convert_document():
    if (request.files.get('document')):
        document=Document(request.files.get('document'))
    elif (not request.files.get('document') and
        request.form.get('document')):
        document=Document(FileStorage(
            StringIO(request.form.get('document')),
            '{name}.{extension}'.format(
                name=random_string(),
                extension=request.form.get('from'))
        ))

    mime_type=document.convert(request.form.get('from'), request.form.get('to'))

    @after_this_request
    def delete_document_files(response):
        document.delete_files()
        return response

    return send_from_directory(
        document.converted_file_directory,
        document.converted_file_name,
        mimetype=mime_type)
app.py 文件源码 项目:image_text_reader 作者: yardstick17 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def post(self):
        file_ = parse_arg_from_requests(arg='image', type=werkzeug.FileStorage, location='files')
        if not file_:
            abort(400, "Required form-data param 'image' type=ImageFile")
        _setup()  # Loads model and weights - takes ~2 seconds
        file_descriptor, filename = tempfile.mkstemp(suffix='.jpg')
        logging.info('Saving file: %s', filename)
        file_.save(filename)
        text_in_image = read_image_and_delete(filename)
        return jsonify(status='success',
                       text_in_image=text_in_image.split('\n'),
                       version='0.0.1',
                       )
main.py 文件源码 项目:NYCSL2 作者: HMProgrammingClub 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument("problemID", type=str, required=True, location="json")
        parser.add_argument("userID", type=str, required=True, location="json")
        parser.add_argument("file", type=FileStorage, required=True, location="files")
        entry = parser.parse_args()

        try:
            if db.problem.find_one({"_id": ObjectId(entry['problemID'])}) == None:
                abort(400)
            if db.user.find_one({"_id": entry['userID']}) == None:
                abort(400)
        except:
            abort(400)

        problemName =  db.problem.find_one({"_id": ObjectId(entry['problemID'])})['name']
        gradingFilePath = os.path.join(os.path.join(PROBLEMS_DIR, problemName.lower()), GRADING_SCRIPT)
        command = "python3 "+gradingFilePath+" \""+entry["file"].stream+"\""
        gradingOutput = subprocess.Popen(shlex.split(command.replace('\\','/')), stdout=subprocess.PIPE).communicate()[0]
        structuredGradingOutput = json.loads(gradingOutput)

        status_code = None
        if "score" in structuredGradingOutput:
            entry["score"] = structuredGradingOutput["score"]
            entry.pop("file")
            db.entry.insert_one(entry)
            status_code = 201
        else:
            status_code = 400

        return jsonify(structuredGradingOutput, status=status_code)
file.py 文件源码 项目:flasky 作者: RoseOu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:oa_qian 作者: sunqb 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:chihu 作者: yelongyu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:pyetje 作者: rorlika 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:Flask-NvRay-Blog 作者: rui7157 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:Flask-NvRay-Blog 作者: rui7157 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:python_ddd_flask 作者: igorvinnicius 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:micro-blog 作者: nickChenyx 项目源码 文件源码 阅读 42 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:python-flask-security 作者: weinbergdavid 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:Lixiang_zhaoxin 作者: hejaxian 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:Hawkeye 作者: tozhengxq 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:ngx_status 作者: YoYoAdorkable 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']
file.py 文件源码 项目:Sudoku-Solver 作者: ayush1997 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def has_file(self):
        '''Return True iff self.data is a FileStorage with file data'''
        if not isinstance(self.data, FileStorage):
            return False
        # filename == None => the field was present but no file was entered
        # filename == '<fdopen>' is for a werkzeug hack:
        #   large file uploads will get stored in a temporary file on disk and
        #   show up as an extra FileStorage with name '<fdopen>'
        return self.data.filename not in [None, '', '<fdopen>']


问题


面经


文章

微信
公众号

扫码关注公众号