From deec2f0ad2546dfc5e88a195b87f48912f058dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sat, 21 May 2022 22:53:54 +0200 Subject: [PATCH] use builtin function --- api/hanyadikhetvan/__init__.py | 11 +++++++++++ api/hanyadikhetvan/function.json | 19 +++++++++++++++++++ api/host.json | 7 +++++++ src/http-common.ts | 2 +- src/services/HHVDataService.ts | 2 +- 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 api/hanyadikhetvan/__init__.py create mode 100644 api/hanyadikhetvan/function.json create mode 100644 api/host.json diff --git a/api/hanyadikhetvan/__init__.py b/api/hanyadikhetvan/__init__.py new file mode 100644 index 0000000..8f609ea --- /dev/null +++ b/api/hanyadikhetvan/__init__.py @@ -0,0 +1,11 @@ +from math import floor +from datetime import date +import azure.functions as func + + +def main(req: func.HttpRequest) -> func.HttpResponse: + startdate = date(2022, 2, 6) + currentweek = floor((date.today() - startdate).days / 7) + return func.HttpResponse( + str(currentweek), + status_code=200) diff --git a/api/hanyadikhetvan/function.json b/api/hanyadikhetvan/function.json new file mode 100644 index 0000000..23b6b50 --- /dev/null +++ b/api/hanyadikhetvan/function.json @@ -0,0 +1,19 @@ +{ + "scriptFile": "__init__.py", + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req", + "methods": [ + "get" + ] + }, + { + "type": "http", + "direction": "out", + "name": "$return" + } + ] +} diff --git a/api/host.json b/api/host.json new file mode 100644 index 0000000..ed89a5e --- /dev/null +++ b/api/host.json @@ -0,0 +1,7 @@ +{ + "version": "2.0", + "functionTimeout": "00:00:10", + "healthMonitor": { + "enabled": false + } +} diff --git a/src/http-common.ts b/src/http-common.ts index 2cbf20b..cc37db9 100644 --- a/src/http-common.ts +++ b/src/http-common.ts @@ -2,7 +2,7 @@ import axios from "axios"; import type { AxiosInstance } from "axios"; const apiClient: AxiosInstance = axios.create({ - baseURL: "https://hanyadikhetvan.tormakristof.eu", + baseURL: "/api", }); diff --git a/src/services/HHVDataService.ts b/src/services/HHVDataService.ts index 8492b17..0b158df 100644 --- a/src/services/HHVDataService.ts +++ b/src/services/HHVDataService.ts @@ -3,7 +3,7 @@ import http from "@/http-common"; /* eslint-disable */ class HHVDataService { getWeekNumber(): Promise { - return http.get("/"); + return http.get("/hanyadikhetvan"); } }