summaryrefslogtreecommitdiffstats
path: root/src/ogRest.py
diff options
context:
space:
mode:
authorAlvaro Neira Ayuso <aneira@soleta.eu>2019-12-13 12:56:11 +0100
committerAlvaro Neira Ayuso <alvaroneay@gmail.com>2020-01-19 19:50:44 +0100
commit694bc492a2cb42179d6341be8d7ad4098a2ac9ce (patch)
tree5dc08fcf85adc17400186e4141b9d95e15b23cfa /src/ogRest.py
parent7548870a923db820380d352f65ff2e05de2ef65d (diff)
Add ogRest class to generate API Rest Responses
This class now, allow us to generate API Rest responses. In the future, the idea is to complete this class with get and post messages if it's needed.
Diffstat (limited to 'src/ogRest.py')
-rw-r--r--src/ogRest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
new file mode 100644
index 0000000..dfc382c
--- /dev/null
+++ b/src/ogRest.py
@@ -0,0 +1,14 @@
+from enum import Enum
+
+class ogResponses(Enum):
+ BAD_REQUEST=0
+ IN_PROGRESS=1
+ OK=2
+
+def getResponse(response):
+ if response == ogResponses.BAD_REQUEST:
+ return 'HTTP/1.0 400 Bad request\r\n\r\n'
+ if response == ogResponses.IN_PROGRESS:
+ return 'HTTP/1.0 202 Accepted\r\n\r\n'
+ if response == ogResponses.OK:
+ return 'HTTP/1.0 200 OK\r\n\r\n'