Skip to content

Commit

Permalink
Try again to block bots
Browse files Browse the repository at this point in the history
  • Loading branch information
rukayaj committed May 12, 2024
1 parent 5d078da commit a8ea12a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ def validate_file_content(file_content):
raise ValueError("\n".join(errors))
return url_list

@app.before_request
def log_request_info():
app.logger.info('Headers: %s', request.headers)
app.logger.info('Body: %s', request.get_data())

@app.before_request
def block_bots():
user_agent = request.headers.get('User-Agent')
user_agent = request.headers.get('User-Agent', '')
if "InternetMeasurement" in user_agent or "Discordbot" in user_agent:
abort(403)

Expand Down

0 comments on commit a8ea12a

Please sign in to comment.