Giter Site home page Giter Site logo

flask-restframework's Introduction

Hi there ๐Ÿ‘‹

  • ๐Ÿ”ญ Iโ€™m currently working on ...
  • ๐ŸŒฑ Iโ€™m currently learning ...
  • ๐Ÿ‘ฏ Iโ€™m looking to collaborate on ...
  • ๐Ÿค” Iโ€™m looking for help with ...
  • ๐Ÿ’ฌ Ask me about ...
  • ๐Ÿ“ซ How to reach me: ...
  • โšก Fun fact: ...

Programming Languages

  • Know : | Python ๏ฝœC++ | Sql | Redis | Mongo |

  • Learning : ๏ฝœGo |

Tools

  • Know : | VScode | Docker | Git |

  • Learning : |Full-Stack Development โšก | Open-Source ๐Ÿ”ฅ | Kubernets

  • Contact me : waro163

waro163's github stats

flask-restframework's People

Contributors

waro163 avatar

Stargazers

 avatar

Watchers

 avatar

flask-restframework's Issues

throttle problem

class AnonRateThrottle(BaseThrottle):
"""
Limits the rate of API calls that may be made by a anonymous users.
The IP address of the request will be used as the unique cache key.
"""
scope = 'anon'
def get_cache_key(self):
if g.current_user and g.current_user.is_authenticated:
return None # Only throttle unauthenticated requests.
return self.cache_format % {
'scope': self.scope,
'ident': self.get_ident()
}
class UserRateThrottle(BaseThrottle):
"""
Limits the rate of API calls that may be made by a given user.
The user id will be used as a unique cache key if the user is
authenticated. For anonymous requests, the IP address of the request will
be used.
"""
scope = 'user'
def get_cache_key(self):
if g.current_user and g.current_user.is_authenticated:
ident = g.current_user.id
else:
ident = self.get_ident()
return self.cache_format % {
'scope': self.scope,
'ident': ident
}

if i use same throttle class in different api, any one api will affect the others' throttling, because they use same cache key in class.
i don't want to write many same throttle class that only changing cache key inside.
so change the above code to support this situation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.