Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigodasilv authored Dec 27, 2023
1 parent a72e20f commit 373a8b9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

app = Flask(__name__)


current_year = datetime.date.today().year
def get_data(url, competitors_nr):
html_doc = requests.get(url)
soup = BeautifulSoup(html_doc.content, 'html.parser')
Expand Down Expand Up @@ -35,23 +35,23 @@ def get_data(url, competitors_nr):
@app.route('/wrc')
def get_standings_wrc(competitors=10):
return get_data(
f'https://www.fia.com/events/world-rally-championship/season-{datetime.date.today().year}/standings',
f'https://www.fia.com/events/world-rally-championship/season-{current_year}/standings',
int(competitors))


@app.route('/f1/<competitors>')
@app.route('/f1')
def get_standings_f1(competitors=20):
return get_data(
f'https://www.fia.com/events/fia-formula-one-world-championship/season-{datetime.date.today().year}/{datetime.date.today().year}-classifications',
f'https://www.fia.com/events/fia-formula-one-world-championship/season-{current_year}/{current_year}-classifications',
int(competitors))


@app.route('/wec/<competitors>')
@app.route('/wec')
def get_standings_wec(competitors=10):
return get_data(
f'https://www.fia.com/events/world-endurance-championship/season-{datetime.date.today().year}/standings',
f'https://www.fia.com/events/world-endurance-championship/season-{current_year}/standings',
int(competitors))


Expand Down

0 comments on commit 373a8b9

Please sign in to comment.