profile
viewpoint
Bobyr Alexey pussbb Ukraine developer

pussbb/Kohana-RPC 5

Kohana 3.X module for XML-RPC protocol

pussbb/Kohana-my-base 4

Module with classes for Kohana framework, which makes developing more easily(as for me)

pussbb/CI_DEV_CMS 3

My CodeIgniter for dev

pussbb/QWebDevIde 3

attempt to make own lightweight development environment

pussbb/JS-stuff 2

some js experiments etc

pussbb/Link-Saver 1

Qt Version of Link Saver

pussbb/pagination 1

A Kohana module for pagination

pussbb/QCoreWindow 1

QCoreWindow

startedVerizon/redshell

started time in 2 days

issue closedpallets/flask

How clear AWS S3 Bucket ClientError in Flask API server?

<!-- This issue tracker is a tool to address bugs in Flask itself. Please use the Pallets Discord or Stack Overflow for general questions about using Flask or issues not related to Flask. -->

<!-- If you'd like to report a bug in Flask, fill out the template below. Provide any extra information that may be useful / related to your problem. Ideally, create an MCVE, which helps us understand the problem and helps check that it is not caused by something in your code. -->

Expected Behavior

<!-- Tell us what should happen. -->

  • This bug occurs in Flask API server to image download. I search this error at Google. I find same issue at this repo. it is here.

https://github.com/boto/botocore/issues/1413

  • This issue is specific time. this error occur in Flask API server run after about 1hours. I don't know this issue. Help me please.

  • My code is it.


@app.route('/inspection', methods=['GET', 'POST'])
def image_inspection():
    if request.method == "GET":
        check_srl = request.args.get('assetCheckSrl')
        origin_url = request.args.get('origin').replace('"','')
        inspection_url = request.args.get('inspection').replace('"','')
        origin_path = origin_url.split('com/')[1]
        inspection_path = inspection_url.split('com/')[1]

        print("check_srl :" , check_srl)
        print("origin_url :" , origin_url) # https://XXXX.s3.ap-northeast-2.amazonaws.com/XXXX/asset/init/1110_asset_201125173650.jpg
        print("inspection_url :" , inspection_url) # https://XXXX-s3.s3.ap-northeast-2.amazonaws.com/XXXX/asset/init/1110_asset_201125173855.jpg
        print("origin_path :" , origin_path) # XXXX/asset/init/1110_asset_201125173650.jpg
        print("inspection_path :" , inspection_path) # XXXX/asset/init/1110_asset_201125173855.jpg

        origin_image = image_origin_object(origin_path)
        time.sleep(1)
        inspection_image = image_inspection_object(inspection_path)
        ~~~~~~~~~~~~~~~~~~~~~~
        ~~~~~~~~~~~~~~~~~~~~~~
        ~~~~~~~~~~~~~~~~~~~~~~
        compare_url = result_save(result_feature['result']['result_path'], inspection_url, inspection_path)

        return jsonify(result_feature)

def image_origin_object(origin_path):
    
    origin_image = './images/' + origin_path.split('init/')[1]
    s3.Bucket(BUCKET_NAME).download_file(origin_path, origin_image)
    
    return origin_image

def image_inspection_object(inspection_path):

    inspection_image = './images/' + inspection_path.split('init/')[1]
    print('inspection_path >>> : ', inspection_path)
    print('inspection_image >>> : ', inspection_image)
    s3.Bucket(BUCKET_NAME).download_file(inspection_path, inspection_image)

    return inspection_image

def result_save(file_name, inspection_url, inspection_path):

    s3_client = boto3.client('s3')
    inspection_url = inspection_url.replace('init','compare')
    KEY = inspection_path.replace('init','compare')
    response = s3_client.upload_file(file_name, BUCKET_NAME, KEY)

    return inspection_url

Actual Behavior

<!-- Tell us what happens instead. -->

  • I make Flask API server for image processing in AWS EC2. AWS S3 Bucket is public setting. AWS EC2 configure already set my KEY, region.

Environment

  • Python version:
(venv) ubuntu:~/environment $ python --version
Python 3.6.9
  • Flask version: Flask==1.1.2 Jinja2==2.11.2 flask-cors==3.0.8
  • Werkzeug version: Werkzeug==1.0.1

closed time in 2 days

WooSung-Jung

issue commentpallets/flask

How clear AWS S3 Bucket ClientError in Flask API server?

Please use Stack Overflow for questions about your own code. This tracker is for issues related to the project itself. Be sure to include a minimal, complete, and verifiable example.

WooSung-Jung

comment created time in 2 days

issue openedpallets/flask

How clear AWS S3 Bucket ClientError in Flask API server?

<!-- This issue tracker is a tool to address bugs in Flask itself. Please use the Pallets Discord or Stack Overflow for general questions about using Flask or issues not related to Flask. -->

<!-- If you'd like to report a bug in Flask, fill out the template below. Provide any extra information that may be useful / related to your problem. Ideally, create an MCVE, which helps us understand the problem and helps check that it is not caused by something in your code. -->

Expected Behavior

<!-- Tell us what should happen. -->

  • This bug occurs in Flask API server to image download. I search this error at Google. I find same issue at this repo. it is here.

https://github.com/boto/botocore/issues/1413

  • This issue is specific time. this error occur in Flask API server run after about 1hours. I don't know this issue. Help me please.

  • My code is it.


@app.route('/inspection', methods=['GET', 'POST'])
def image_inspection():
    if request.method == "GET":
        check_srl = request.args.get('assetCheckSrl')
        origin_url = request.args.get('origin').replace('"','')
        inspection_url = request.args.get('inspection').replace('"','')
        origin_path = origin_url.split('com/')[1]
        inspection_path = inspection_url.split('com/')[1]

        print("check_srl :" , check_srl)
        print("origin_url :" , origin_url) # https://XXXX.s3.ap-northeast-2.amazonaws.com/XXXX/asset/init/1110_asset_201125173650.jpg
        print("inspection_url :" , inspection_url) # https://XXXX-s3.s3.ap-northeast-2.amazonaws.com/XXXX/asset/init/1110_asset_201125173855.jpg
        print("origin_path :" , origin_path) # XXXX/asset/init/1110_asset_201125173650.jpg
        print("inspection_path :" , inspection_path) # XXXX/asset/init/1110_asset_201125173855.jpg

        origin_image = image_origin_object(origin_path)
        time.sleep(1)
        inspection_image = image_inspection_object(inspection_path)
        ~~~~~~~~~~~~~~~~~~~~~~
        ~~~~~~~~~~~~~~~~~~~~~~
        ~~~~~~~~~~~~~~~~~~~~~~
        compare_url = result_save(result_feature['result']['result_path'], inspection_url, inspection_path)

        return jsonify(result_feature)

def image_origin_object(origin_path):
    
    origin_image = './images/' + origin_path.split('init/')[1]
    s3.Bucket(BUCKET_NAME).download_file(origin_path, origin_image)
    
    return origin_image

def image_inspection_object(inspection_path):

    inspection_image = './images/' + inspection_path.split('init/')[1]
    print('inspection_path >>> : ', inspection_path)
    print('inspection_image >>> : ', inspection_image)
    s3.Bucket(BUCKET_NAME).download_file(inspection_path, inspection_image)

    return inspection_image

def result_save(file_name, inspection_url, inspection_path):

    s3_client = boto3.client('s3')
    inspection_url = inspection_url.replace('init','compare')
    KEY = inspection_path.replace('init','compare')
    response = s3_client.upload_file(file_name, BUCKET_NAME, KEY)

    return inspection_url

Actual Behavior

<!-- Tell us what happens instead. -->

  • I make Flask API server for image processing in AWS EC2. AWS S3 Bucket is public setting. AWS EC2 configure already set my KEY, region.

Environment

  • Python version:
(venv) ubuntu:~/environment $ python --version
Python 3.6.9
  • Flask version: Flask==1.1.2 Jinja2==2.11.2 flask-cors==3.0.8
  • Werkzeug version: Werkzeug==1.0.1

created time in 2 days

startedStuxend/siras

started time in 2 days

issue closedpallets/flask

PUT route requires a body to work

Having a route like @app.route("/my-put-url/<obj_id>", methods=["PUT"]). The route only needs access to obj_id which is provided in the URI. There's no need for a body in this case. To work around it, I need to provide {} in the body for it to work.

Expected Behavior

When making a PUT request without a body, which I think is a valid request under RFC, such request should be handled by Flask.

Actual Behavior

Flask however returns a 400 BadRequest response. In postman, it renders like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>

Environment

  • Python version: 3.7
  • Flask version: 1.1.2
  • Werkzeug version: 1.0.1

closed time in 3 days

yellowmamba

issue commentpallets/flask

PUT route requires a body to work

Flask won't require you to provide a body for PUT requests. There is something wrong with your code inside the view function. You can test this behavior simply with a minimal application:

from flask import Flask

app = Flask(__name__)

@app.route('/put', methods=['PUT'])
def test_put():
    return 'Hello'

Since you didn't provide the view function code and the request detail, there is nothing I can help with. Besides, please use Stack Overflow for questions about your own code. This tracker is for issues related to the project itself. Be sure to include a minimal, complete, and verifiable example.

yellowmamba

comment created time in 3 days

issue commentpallets/flask

SESSION_COOKIE_SAMESITE not woking

Then there's something else wrong with your code. As demonstrated in the example above, setting samesite=none works as expected.

Please use Stack Overflow for questions about your own code. This tracker is for issues related to the project itself. Be sure to include a minimal, complete, and verifiable example.

keehl1213

comment created time in 3 days

issue commentpallets/flask

SESSION_COOKIE_SAMESITE not woking

"None"

I have already tried and failed. It's not woking.

keehl1213

comment created time in 3 days

issue openedpallets/flask

PUT route requires a body to work

Having a route like @app.route("/my-put-url/<obj_id>", methods=["PUT"]). The route only needs access to obj_id which is provided in the URI. There's no need for a body in this case. To work around it, I need to provide

Expected Behavior

When making a PUT request without a body, which I think is a valid request under RFC, such request should be handled by Flask.

Actual Behavior

Flask however returns a 400 BadRequest response. In postman, it renders like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>The browser (or proxy) sent a request that this server could not understand.</p>

Environment

  • Python version: 3.7
  • Flask version: 1.1.2
  • Werkzeug version: 1.0.1

created time in 3 days

issue closedpallets/flask

SESSION_COOKIE_SAMESITE not woking

<!-- This issue tracker is a tool to address bugs in Flask itself. Please use the Pallets Discord or Stack Overflow for general questions about using Flask or issues not related to Flask. -->

<!-- If you'd like to report a bug in Flask, fill out the template below. Provide any extra information that may be useful / related to your problem. Ideally, create an MCVE, which helps us understand the problem and helps check that it is not caused by something in your code. -->

I wanted to embed web page to iframe, but got cross-site issue. The solution was set SESSION_COOKIE_SAMESITE = None. The feature have existed after flask 1.0 #2607 changed log

But no matter what I set, the samesite attribute has never shown up.

I can assure that flask and werkzung both are right version. #1549

Expected Behavior

<!-- Tell us what should happen. -->

Set-Cookie: session=<session>; Expires=Mon, 23-Nov-2020 11:58:00 GMT; Path=/; secure; samesite=<whatever I set>

Actual Behavior

<!-- Tell us what happens instead. -->

Set-Cookie: session=<session>; Expires=Mon, 23-Nov-2020 11:58:00 GMT; Path=/; secure

Environment

  • Python version: 3.6
  • Flask version: 1.1.2
  • Werkzeug version: 1.0.1

closed time in 3 days

keehl1213

issue commentpallets/flask

SESSION_COOKIE_SAMESITE not woking

The literal value None means "not set". Set it to the string "None" to set it to samesite=none.

keehl1213

comment created time in 3 days

issue openedpallets/flask

SESSION_COOKIE_SAMESITE not woking

<!-- This issue tracker is a tool to address bugs in Flask itself. Please use the Pallets Discord or Stack Overflow for general questions about using Flask or issues not related to Flask. -->

<!-- If you'd like to report a bug in Flask, fill out the template below. Provide any extra information that may be useful / related to your problem. Ideally, create an MCVE, which helps us understand the problem and helps check that it is not caused by something in your code. -->

I wanted to embed web page to iframe, but got cross-site issue. The solution was set SESSION_COOKIE_SAMESITE = None. The feature have existed after flask 1.0 #2607 changed log

But no matter what I set, the samesite attribute has never shown up.

I can assure that flask and werkzung both are right version. #1549

Expected Behavior

<!-- Tell us what should happen. -->

Set-Cookie: session=<session>; Expires=Mon, 23-Nov-2020 11:58:00 GMT; Path=/; secure; samesite=<whatever I set>

Actual Behavior

<!-- Tell us what happens instead. -->

Set-Cookie: session=<session>; Expires=Mon, 23-Nov-2020 11:58:00 GMT; Path=/; secure

Environment

  • Python version: 3.6
  • Flask version: 1.1.2
  • Werkzeug version: 1.0.1

created time in 3 days

started0xdekster/ReconNote

started time in 3 days

startedjopohl/urh

started time in 3 days

push eventpallets/flask

pre-commit-ci[bot]

commit sha cd3a93a9c1aaf8440d366cbebbc852e1033914cd

[pre-commit.ci] pre-commit autoupdate

view details

Grey Li

commit sha 28a3eb106c20eb6c3b9064f27f07a2ca89c0a4d7

Merge pull request #3842 from pallets/pre-commit-ci-update-config [pre-commit.ci] pre-commit autoupdate

view details

push time in 4 days

delete branch pallets/flask

delete branch : pre-commit-ci-update-config

delete time in 4 days

pull request commentpallets/flask

Update cli.rst, repeated word "that" in line 258

Looking it and reading with care, it's good like it is now. Sorry for the PR :P

diegogarromolina

comment created time in 4 days

PR closed pallets/flask

Update cli.rst, repeated word "that" in line 258

Describe what this patch does to fix the issue.

Link to any relevant issues or pull requests.

<!-- Commit checklist:

  • add tests that fail without the patch
  • ensure all tests pass with pytest
  • add documentation to the relevant docstrings or pages
  • add versionadded or versionchanged directives to relevant docstrings
  • add a changelog entry if this patch changes code

Tests, coverage, and docs will be run automatically when you submit the pull request, but running them yourself can save time. -->

+1 -1

1 comment

1 changed file

diegogarromolina

pr closed time in 4 days

pull request commentpallets/flask

Update cli.rst, repeated word "that" in line 258

Thanks for looking at this. However, it's correct as-is, even if it looks weird. It sounds less correct to me when it's removed.

diegogarromolina

comment created time in 4 days

PR opened pallets/flask

Update cli.rst, repeated word "that" in line 258

Describe what this patch does to fix the issue.

Link to any relevant issues or pull requests.

<!-- Commit checklist:

  • add tests that fail without the patch
  • ensure all tests pass with pytest
  • add documentation to the relevant docstrings or pages
  • add versionadded or versionchanged directives to relevant docstrings
  • add a changelog entry if this patch changes code

Tests, coverage, and docs will be run automatically when you submit the pull request, but running them yourself can save time. -->

+1 -1

0 comment

1 changed file

pr created time in 4 days

startedBashfuscator/Bashfuscator

started time in 4 days

issue closedpallets/flask

before_request handler in Methodview class

Could we have a before_request handler in MethodView? It could be called as part of the MethodView.dispatch_request method.

It would be called if any subclass of MethodView implements a before_request method, for instance:

from flask.views import MethodView


class BaseView(MethodView):
    """ Base view  """

    def before_request(self):
        print("before_request called")

flask/views.py:

class MethodView(with_metaclass(MethodViewType, View)):
    """A class-based view that ... """

    def before_request(self, *args, **kwargs):
        """ Called before the request is dispatched to the request method handler """
        pass

    def dispatch_request(self, *args, **kwargs):

        meth = getattr(self, request.method.lower(), None)

        self.before_request(*args, **kwargs)

        # or ...

        before_func = getattr(self, "before_request", None)
        if before_func:
            before_func(*args, **kwargs)

        # If the request method is HEAD and we don't have a handler for it
        # retry with GET.
        if meth is None and request.method == "HEAD":
            meth = getattr(self, "get", None)

        assert meth is not None, "Unimplemented method %r" % request.method
        return meth(*args, **kwargs)

closed time in 4 days

Julian-Nash

issue commentpallets/flask

before_request handler in Methodview class

Thanks for thinking about this. However, I don't want to add complexity to MethodView at this time. As you've shown, this is already possible by subclassing and overriding the dispatch_request method, which is the intended way to extend this and many other APIs in Flask.

Julian-Nash

comment created time in 4 days

issue commentpallets/flask

before_request handler in Methodview class

Probably better implemented in the View class

flask/views.py

class View(object):
    """Alternative way to use .... """

    methods = None
    provide_automatic_options = None
    decorators = ()

    def before_request(self, *args, **kwargs):
        """ Called before dispatch_request  """
        pass

    def dispatch_request(self):
        """Subclasses have to override this method to implement the
        actual view function code.  This method is called with all
        the arguments from the URL rule.
        """
        raise NotImplementedError()

    @classmethod
    def as_view(cls, name, *class_args, **class_kwargs):
        """Converts the class ... """

        def view(*args, **kwargs):
            self = view.view_class(*class_args, **class_kwargs)
            self.before_request(*args, **kwargs)
            return self.dispatch_request(*args, **kwargs)

        if cls.decorators:
            view.__name__ = name
            view.__module__ = cls.__module__
            for decorator in cls.decorators:
                view = decorator(view)

        # We attach the view class to the view function for two reasons:
        # first of all it allows us to easily figure out what class-based
        # view this thing came from, secondly it's also used for instantiating
        # the view class so you can actually replace it with something else
        # for testing purposes and debugging.
        view.view_class = cls
        view.__name__ = name
        view.__doc__ = cls.__doc__
        view.__module__ = cls.__module__
        view.methods = cls.methods
        view.provide_automatic_options = cls.provide_automatic_options
        return view
Julian-Nash

comment created time in 4 days

issue commentpallets/flask

before_request handler in MethodView

Actually, before_request could be implemented in theViewclass inflask/views.py`

Julian-Nash

comment created time in 4 days

issue openedpallets/flask

before_request handler in MethodView

Could we have a before_request handler in MethodView? It could be called as part of the MethodView.dispatch_request method.

It would be called if any subclass of MethodView implements a before_request method, for instance:

from flask.views import MethodView


class BaseView(MethodView):
    """ Base view  """

    def before_request(self):
        print("before_request called")

flask/views.py:

class MethodView(with_metaclass(MethodViewType, View)):
    """A class-based view that ... """

    def before_request(self, *args, **kwargs):
        """ Called before the request is dispatched to the request method handler """
        pass

    def dispatch_request(self, *args, **kwargs):

        meth = getattr(self, request.method.lower(), None)

        self.before_request(*args, **kwargs)

        # or ...

        before_func = getattr(self, "before_request", None)
        if before_func:
            before_func(*args, **kwargs)

        # If the request method is HEAD and we don't have a handler for it
        # retry with GET.
        if meth is None and request.method == "HEAD":
            meth = getattr(self, "get", None)

        assert meth is not None, "Unimplemented method %r" % request.method
        return meth(*args, **kwargs)

created time in 4 days

startedsensepost/routopsy

started time in 4 days

create barnchpallets/flask

branch : pre-commit-ci-update-config

created branch time in 4 days

more