From 85082a7bd96ff2d4a7c02f91d4228e4e5fcb43e9 Mon Sep 17 00:00:00 2001 From: Valentin <43043885+itsmrval@users.noreply.github.com> Date: Tue, 23 Jan 2024 13:36:44 +0100 Subject: [PATCH] bug fix --- app.py | 9 +++---- example.env | 3 ++- index.py | 62 -------------------------------------------- templates/index.html | 2 +- 4 files changed, 7 insertions(+), 69 deletions(-) delete mode 100644 index.py diff --git a/app.py b/app.py index 021451b..db1d64b 100644 --- a/app.py +++ b/app.py @@ -1,5 +1,5 @@ from flask import Flask, redirect, url_for, session, render_template, Response, request -from flask_oauthlib.client import OAuth +from flask_oauthlib.client import OAuth, OAuthRemoteApp from flask_sqlalchemy import SQLAlchemy from datetime import datetime, timedelta from icalendar import Calendar, Event @@ -9,7 +9,7 @@ load_dotenv() app = Flask(__name__) -app.config['SECRET_KEY'] = 'fjlksjfnklsdfnsdklfnsdkjfnsdjkfnds' +app.config['SECRET_KEY'] = os.getenv('SESSION_SECRET') app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) @@ -145,7 +145,6 @@ def generate_ical(events): cal = Calendar() for event_data in events: event = Event() - print("event: ", event) event.add('summary', f"{event_data['hometeamTricode']} vs {event_data['awayteamTricode']} 🏀") event.add('location', f"🏟 {event_data['arenaName']}, {event_data['arenaCity']}") event.add("description", f"🎖️Scores: \n{event_data['hometeamName']} {event_data['hometeamScore']} - {event_data['awayteamScore']} {event_data['awayteamName']}") @@ -237,7 +236,7 @@ def login(): @app.route('/login/google') def google_redirect(): - return google.authorize(callback=url_for('authorized', _external=True)) + return google.authorize(callback=url_for('authorized', _external=True, _scheme='https')) @app.route('/logout') def logout(): @@ -263,4 +262,4 @@ if __name__ == '__main__': with app.app_context(): db.create_all() - app.run(debug=True, port=5050) \ No newline at end of file + app.run(debug=True, port=8000, host='127.0.0.1') diff --git a/example.env b/example.env index 728f5fd..d682a97 100644 --- a/example.env +++ b/example.env @@ -1,2 +1,3 @@ GOOGLE_KEY="" -GOOGLE_SECRET="" \ No newline at end of file +GOOGLE_SECRET="" +SESSION_SECRET="" \ No newline at end of file diff --git a/index.py b/index.py deleted file mode 100644 index 96f5151..0000000 --- a/index.py +++ /dev/null @@ -1,62 +0,0 @@ -import requests -import json - -# URL du JSON -url = "https://cdn.nba.com/static/json/staticData/scheduleLeagueV2.json" - -# Obtenir le contenu JSON de l'URL -response = requests.get(url) -data = response.json() - -# Liste des matchs avec les informations demandées -matches_info = [] - -for game_date in data['leagueSchedule']['gameDates']: - for game in game_date['games']: - match_info = { - 'gameDateTimeUTC': game['gameDateTimeUTC'], - 'weekNumber': game['weekNumber'], - 'arenaName': game['arenaName'], - 'seriesText': game['seriesText'], - 'hometeamName': game['homeTeam']['teamName'], - 'awayteamName': game['awayTeam']['teamName'], - } - matches_info.append(match_info) - - -teams_dict = { - 1: "Lakers", - 2: "Heat", - 3: "Warriors", - 4: "Celtics", - 5: "Spurs", - 6: "Knicks", - 7: "Pistons", - 8: "Magic", - 9: "Suns", - 10: "Pacers", - 11: "Jazz", - 12: "Trail Blazers", - 13: "Raptors", - 14: "Mavericks", - 15: "Bucks", - 16: "Thunder", - 17: "Bulls", - 18: "Pelicans", - 19: "Rockets", - 20: "Kings", - 21: "Clippers", - 22: "Cavaliers", - 23: "Hawks", - 24: "Grizzlies", - 25: "Nuggets", - 26: "Hornets", - 27: "76ers", - 28: "Wizards", - 29: "Timberwolves", - 30: "Nets" -} - -for i in matches_info: - if (i['hometeamName'] == teams_dict[1] or i['awayteamName'] == teams_dict[1]): - print(i['hometeamName'] + " vs " + i['awayteamName'] + " " + i['gameDateTimeUTC']) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 8e73845..3247871 100644 --- a/templates/index.html +++ b/templates/index.html @@ -75,7 +75,7 @@