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 11, 2023
1 parent 812450f commit 226b41a
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 @@ -1669,6 +1669,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

Check warning on line 1678 in robotoff/app/api.py

View check run for this annotation

Codecov / codecov/patch

robotoff/app/api.py#L1676-L1678

Added lines #L1676 - L1678 were not covered by tests


cors = CORS(
allow_all_origins=True,
allow_all_headers=True,
Expand Down Expand Up @@ -1731,3 +1740,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 226b41a

Please sign in to comment.