Update tests

This commit is contained in:
Jose De Freitas 2021-03-02 15:04:04 -05:00
parent 64cb2816cc
commit d5b623991a
4 changed files with 7 additions and 13 deletions

View File

@ -1 +1 @@
web: gunicorn api:app
web: gunicorn main:app

View File

@ -1,10 +1,10 @@
{
"Tech_With_Tim": 0,
"Tech_With_Tim": 11,
"Derek_Banas": 0,
"Don_Jones": 0,
"Corey_Schafer": 0,
"Brian_Will": 0,
"LearningLad": 0,
"LearningLad": -7,
"David_Bombal": 0,
"Ben_Eater": 0,
"The_Coding_Train": 0,

View File

@ -1,5 +1,4 @@
import json
from datetime import datetime
from flask import Flask, jsonify, make_response, request
from flask_limiter import Limiter
from flask_limiter.util import get_remote_address
@ -53,11 +52,6 @@ def get_channel(channel):
with open("data.json", "w", encoding="utf8") as write_data:
json.dump(channels, write_data, indent=4)
# Write to log file.
with open("log.txt", "a") as append:
today = datetime.today().strftime('%Y-%m-%d-%H:%M')
append.write(f"\n{vote.title()}d {channel} on {today}")
return f"You {vote}d successfully the channel {channel}."
else:
return "Channel not found on the list."
@ -72,7 +66,8 @@ def get_channel(channel):
def img_channel(channel):
""" Returns the YouTube score in a svg image. """
svg_image = f"""
if channel in channels:
svg_image = f"""
<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px"
width="52px" height="22px" viewBox="0 0 52 22" fill="none">
<style>
@ -90,7 +85,6 @@ def img_channel(channel):
</svg>
"""
if channel in channels:
response = make_response(svg_image)
response.headers.set('Content-Type', 'image/svg+xml')
return response
@ -99,4 +93,4 @@ def img_channel(channel):
if __name__ == "__main__":
app.run()
app.run(debug=True)

View File

@ -32,4 +32,4 @@ video quality, coverage of the topics it explains, among others), but, of course
so I think being able to receive opinions from all users is a good way to filter and have truly
awesome content based on the community's opinion.
<img src="127.0.0.1:5000/channels/LearningLad/image.svg">
<img src="http://127.0.0.1:5000/channels/Tech_With_Tim/image.svg">