-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from tblanarik/tblanarik/table-cleanup-3
Table cleanup function
- Loading branch information
Showing
2 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import logging | ||
|
||
def cleanup(): | ||
logging.info("Executing table cleanup function") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import logging | ||
import azure.functions as func | ||
import spotbot as sb | ||
import cleanup | ||
|
||
app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION) | ||
|
||
@app.route(route="spotbot", methods=[func.HttpMethod.POST]) | ||
def spotbot(req: func.HttpRequest) -> func.HttpResponse: | ||
sb.run(req) | ||
return func.HttpResponse(status_code=202) | ||
try: | ||
sb.run(req) | ||
except Exception as _excpt: | ||
logging.error(f"Exception occurred: {_excpt}") | ||
return func.HttpResponse(body=f"Exception occurred: {_excpt}", status_code=500) | ||
else: | ||
return func.HttpResponse(status_code=202) | ||
|
||
@app.route(route="manual_cleanup", methods=[func.HttpMethod.POST]) | ||
def manual_cleanup(req: func.HttpRequest) -> func.HttpResponse: | ||
cleanup.cleanup() |