Skip to content

Commit

Permalink
fix: add robots.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Aug 14, 2023
1 parent 3b8680b commit 10387ff
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions robotoff/app/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,15 @@ def on_get(self, req: falcon.Request, resp: falcon.Response):
resp.media = response


class RobotsTxtResource:
def on_get(self, req: falcon.Request, resp: falcon.Response):
# Disallow completely indexation: otherwise web crawlers send millions
# of requests to Robotoff (420k requests/day by Google alone)
resp.body = "User-agent: *\nDisallow: /\n"
resp.content_type = falcon.MEDIA_TEXT
resp.status = falcon.HTTP_200


cors = CORS(
allow_all_origins=True,
allow_all_headers=True,
Expand Down Expand Up @@ -1736,3 +1745,4 @@ def on_get(self, req: falcon.Request, resp: falcon.Response):
api.add_route("/api/v1/users/statistics/{username}", UserStatisticsResource())
api.add_route("/api/v1/predictions", PredictionCollection())
api.add_route("/api/v1/annotation/collection", LogoAnnotationCollection())
api.add_route("/robots.txt", RobotsTxtResource())

0 comments on commit 10387ff

Please sign in to comment.