Skip to content

Commit

Permalink
Cronjobs test
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaTerenz committed Feb 21, 2024
1 parent 6eb2210 commit 42af4ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from dataclasses import dataclass
from datetime import date
import requests
Expand Down Expand Up @@ -102,6 +103,13 @@ def index():
repos=repos,
contacts=contacts)

@app.route('/api/cron/reload-repos')
def reload_repos():
secret = os.environ.get("CRON_SECRET", -1)
if secret != -1 and request.headers.get('Authorization') != f"Bearer {os.environ['CRON_SECRET']}":
return "I AIN'T RELOADING REPOS FOR YOU, BUSTER", 403

return "Reloading repos...", 200

if __name__ == '__main__':
app.run()
6 changes: 5 additions & 1 deletion vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
],
"routes": [
{ "src": "/(.*)", "dest": "/app.py" }
]
],
"crons": [{
"path": "/api/cron/reload-repos",
"schedule": "*/1 * * * *"
}]
}

0 comments on commit 42af4ea

Please sign in to comment.