From d71a063918ee309b4480799644c8b2a2b375553a Mon Sep 17 00:00:00 2001 From: Airi <61052022+Airiuwu@users.noreply.github.com> Date: Tue, 27 Jul 2021 20:26:27 -0400 Subject: [PATCH 1/7] spaces ;-; --- handlers/submitModularHandler.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/submitModularHandler.pyx b/handlers/submitModularHandler.pyx index d491a101..4ddf9000 100644 --- a/handlers/submitModularHandler.pyx +++ b/handlers/submitModularHandler.pyx @@ -31,7 +31,7 @@ from objects import beatmap from objects import glob from objects import score from objects import scoreboard -from objects.charts import BeatmapChart, OverallChart , OverallChartFailed , BeatmapChartFailed +from objects.charts import BeatmapChart, OverallChart, OverallChartFailed, BeatmapChartFailed from secret import butterCake class handler(requestsManager.asyncRequestHandler): From a5fcca303da1a6174c73fdcb1841aca985c58de6 Mon Sep 17 00:00:00 2001 From: Jacob <61052022+Airiuwu@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:40:33 -0700 Subject: [PATCH 2/7] Update lets.py --- lets.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lets.py b/lets.py index 99da3cf7..f49c9da2 100644 --- a/lets.py +++ b/lets.py @@ -45,6 +45,7 @@ from handlers import uploadScreenshotHandler from handlers import commentHandler from handlers import seasonalHandler +from handlers import difficultyRatingHelper from helpers import consoleHelper from common import agpl from objects import glob @@ -92,6 +93,8 @@ def make_app(): (r"/web/osu-addfavourite.php", emptyHandler.handler), (r"/loadTest", loadTestHandler.handler), + + (r"/difficulty-rating", difficultyRatingHandler.handler), ], default_handler_class=defaultHandler.handler) From 7b3a2b99883b9fe616cf7c8611dc4251b07468a2 Mon Sep 17 00:00:00 2001 From: Jacob <61052022+Airiuwu@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:41:38 -0700 Subject: [PATCH 3/7] Create difficultyRatingHandler.py --- handlers/difficultyRatingHandler.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 handlers/difficultyRatingHandler.py diff --git a/handlers/difficultyRatingHandler.py b/handlers/difficultyRatingHandler.py new file mode 100644 index 00000000..15b58b87 --- /dev/null +++ b/handlers/difficultyRatingHandler.py @@ -0,0 +1,19 @@ +import requests +import tornado.gen +import tornado.web + +from common.log import logUtils as log +from common.web import requestsManager + +class handler(requestsManager.asyncRequestHandler): + @tornado.web.asynchronous + @tornado.gen.engine + def asyncPost(self): + try: + headers = {'Content-type': 'application/json'} + data = self.request.body + response = requests.post("https://osu.ppy.sh/difficulty-rating", data=data, headers=headers) + self.write(response.text) + except Exception as e: + log.error("difficulty-rating failed: {}".format(e)) + self.write("") From 6bfdca39e1e4ad4cc301ab070ba76947b4d0bc5f Mon Sep 17 00:00:00 2001 From: Jacob <61052022+Airiuwu@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:43:39 -0700 Subject: [PATCH 4/7] Create endpoint for /difficulty-rating --- lets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lets.py b/lets.py index f49c9da2..d4414549 100644 --- a/lets.py +++ b/lets.py @@ -45,7 +45,7 @@ from handlers import uploadScreenshotHandler from handlers import commentHandler from handlers import seasonalHandler -from handlers import difficultyRatingHelper +from handlers import difficultyRatingHandler from helpers import consoleHelper from common import agpl from objects import glob From 7717940bac921aa9676f1ceededc508e5b7cb07f Mon Sep 17 00:00:00 2001 From: Jacob <61052022+Airiuwu@users.noreply.github.com> Date: Fri, 22 Oct 2021 20:44:09 -0700 Subject: [PATCH 5/7] Create handler for /difficulty-rating From 30e617d57e2563a89334c8137f843101bb73c6df Mon Sep 17 00:00:00 2001 From: Jacob <61052022+Airiuwu@users.noreply.github.com> Date: Sat, 23 Oct 2021 02:48:15 -0400 Subject: [PATCH 6/7] yeah fuck you github --- handlers/difficultyRatingHandler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/difficultyRatingHandler.py b/handlers/difficultyRatingHandler.py index 15b58b87..438b1999 100644 --- a/handlers/difficultyRatingHandler.py +++ b/handlers/difficultyRatingHandler.py @@ -11,7 +11,7 @@ class handler(requestsManager.asyncRequestHandler): def asyncPost(self): try: headers = {'Content-type': 'application/json'} - data = self.request.body + data = self.request.body response = requests.post("https://osu.ppy.sh/difficulty-rating", data=data, headers=headers) self.write(response.text) except Exception as e: From f14c7cf23de438a5163d476d597fe714c3fa5c79 Mon Sep 17 00:00:00 2001 From: Jacob <61052022+Airiuwu@users.noreply.github.com> Date: Sun, 14 Nov 2021 02:28:40 -0500 Subject: [PATCH 7/7] easier/quicker method --- handlers/difficultyRatingHandler.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/handlers/difficultyRatingHandler.py b/handlers/difficultyRatingHandler.py index 438b1999..934129df 100644 --- a/handlers/difficultyRatingHandler.py +++ b/handlers/difficultyRatingHandler.py @@ -1,19 +1,14 @@ -import requests -import tornado.gen -import tornado.web - -from common.log import logUtils as log +from tornado.gen import engine +from tornado.web import asynchronous from common.web import requestsManager class handler(requestsManager.asyncRequestHandler): - @tornado.web.asynchronous - @tornado.gen.engine + @asynchronous + @engine def asyncPost(self): try: - headers = {'Content-type': 'application/json'} - data = self.request.body - response = requests.post("https://osu.ppy.sh/difficulty-rating", data=data, headers=headers) - self.write(response.text) - except Exception as e: - log.error("difficulty-rating failed: {}".format(e)) + self.set_status(307, "Moved Temporarily") + self.add_header("Location", f"https://osu.ppy.sh/difficulty-rating") + except ValueError: + self.set_status(400) self.write("")