Set cooldown

This commit is contained in:
Jose De Freitas 2021-02-28 20:37:04 -05:00
parent 19ce1af732
commit 7c98a15263
2 changed files with 17 additions and 1 deletions

View File

@ -16,6 +16,13 @@ def list_channels():
@api_channels.route("/channels/<channel>")
def get_channel(channel):
"""
If no query specified, prints the name of the
YouTube channel typed. When a query with the
name "vote" is given, adds or substracts 1
from the specified YouTube score.
"""
if "vote" in request.args:
vote = str(request.args["vote"])
@ -42,6 +49,7 @@ def get_channel(channel):
@api_channels.route("/channels/<channel>/image.svg")
def img_channel(channel):
""" Returns the YouTube score in a svg image. """
if channel in channels:
return f"""
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"

View File

@ -1,8 +1,16 @@
from flask import Flask
from api.api import api_channels
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
app = Flask(__name__)
limiter = Limiter(
app,
key_func=get_remote_address,
default_limits=["1200 per day", "50 per hour"]
)
app.register_blueprint(api_channels)
@ -12,4 +20,4 @@ def main():
if __name__ == "__main__":
app.run(debug=True)
app.run()