mirror of
https://github.com/JoseDeFreitas/awesome-youtubers.git
synced 2025-01-03 03:20:48 -05:00
Change folder structure
This commit is contained in:
parent
bdd676a801
commit
9f55cf48a3
@ -1 +1 @@
|
||||
web: gunicorn server:app
|
||||
web: gunicorn main:app
|
@ -1 +0,0 @@
|
||||
-
|
@ -1,21 +1,34 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
from flask import Blueprint, request, jsonify, make_response
|
||||
from flask import Flask, jsonify, make_response, request
|
||||
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"]
|
||||
)
|
||||
|
||||
with open("data.json", "r", encoding="utf8") as read_data:
|
||||
channels = json.load(read_data)
|
||||
|
||||
api_channels = Blueprint('api_channels', __name__)
|
||||
|
||||
@app.route("/")
|
||||
def main():
|
||||
return "Awesome YouTubers voting system website."
|
||||
|
||||
|
||||
@api_channels.route("/channels/all")
|
||||
@app.route("/channels/all")
|
||||
def list_channels():
|
||||
""" Lists all channels in the database. """
|
||||
|
||||
return jsonify(channels)
|
||||
|
||||
|
||||
@api_channels.route("/channels/<channel>")
|
||||
@app.route("/channels/<channel>")
|
||||
def get_channel(channel):
|
||||
"""
|
||||
If no query specified, prints the name of the
|
||||
@ -55,7 +68,7 @@ def get_channel(channel):
|
||||
return "Channel not found on the list."
|
||||
|
||||
|
||||
@api_channels.route("/channels/<channel>/image.svg")
|
||||
@app.route("/channels/<channel>/image.svg")
|
||||
def img_channel(channel):
|
||||
""" Returns the YouTube score in a svg image. """
|
||||
|
||||
@ -83,3 +96,7 @@ def img_channel(channel):
|
||||
return response
|
||||
else:
|
||||
return "Channel not found on the list"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
@ -1,23 +0,0 @@
|
||||
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)
|
||||
|
||||
|
||||
@app.route("/")
|
||||
def main():
|
||||
return "Awesome YouTubers voting system website."
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
Loading…
Reference in New Issue
Block a user