From c013f1c76bd69847eb441d7ba34290b6f0b2d20b Mon Sep 17 00:00:00 2001 From: pappac Date: Thu, 8 Aug 2024 18:23:13 +0100 Subject: [PATCH] initial commit --- .dockerignore | 5 +++++ .gitignore | 2 ++ Dockerfile | 17 +++++++++++++++++ __init__.py | 0 requirements.txt | 1 + server/__init__.py | 0 server/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 120 bytes server/__pycache__/app.cpython-312.pyc | Bin 0 -> 781 bytes .../blueprint_manager.cpython-312.pyc | Bin 0 -> 370 bytes server/__pycache__/blueprints.cpython-312.pyc | Bin 0 -> 365 bytes server/__pycache__/config.cpython-312.pyc | Bin 0 -> 501 bytes .../register_blueprints.cpython-312.pyc | Bin 0 -> 372 bytes server/app.py | 9 +++++++++ server/blueprints/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 131 bytes .../__pycache__/blueprints.cpython-312.pyc | Bin 0 -> 374 bytes .../__pycache__/index.cpython-312.pyc | Bin 0 -> 894 bytes .../__pycache__/register.cpython-312.pyc | Bin 0 -> 370 bytes server/blueprints/index.py | 15 +++++++++++++++ server/config.py | 6 ++++++ server/dev_utils/__init__.py | 0 server/helpers/__init__.py | 0 server/register_blueprints.py | 4 ++++ server/services/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 129 bytes .../__pycache__/health_service.cpython-312.pyc | Bin 0 -> 382 bytes server/services/health_service.py | 4 ++++ server/tests/__init__.py | 0 28 files changed, 63 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 __init__.py create mode 100644 requirements.txt create mode 100644 server/__init__.py create mode 100644 server/__pycache__/__init__.cpython-312.pyc create mode 100644 server/__pycache__/app.cpython-312.pyc create mode 100644 server/__pycache__/blueprint_manager.cpython-312.pyc create mode 100644 server/__pycache__/blueprints.cpython-312.pyc create mode 100644 server/__pycache__/config.cpython-312.pyc create mode 100644 server/__pycache__/register_blueprints.cpython-312.pyc create mode 100644 server/app.py create mode 100644 server/blueprints/__init__.py create mode 100644 server/blueprints/__pycache__/__init__.cpython-312.pyc create mode 100644 server/blueprints/__pycache__/blueprints.cpython-312.pyc create mode 100644 server/blueprints/__pycache__/index.cpython-312.pyc create mode 100644 server/blueprints/__pycache__/register.cpython-312.pyc create mode 100644 server/blueprints/index.py create mode 100644 server/config.py create mode 100644 server/dev_utils/__init__.py create mode 100644 server/helpers/__init__.py create mode 100644 server/register_blueprints.py create mode 100644 server/services/__init__.py create mode 100644 server/services/__pycache__/__init__.cpython-312.pyc create mode 100644 server/services/__pycache__/health_service.cpython-312.pyc create mode 100644 server/services/health_service.py create mode 100644 server/tests/__init__.py diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e0a04fc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +/.venv/ +/.idea/ +.dockerignore +.gitignore +Dockerfile \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ad75105 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.venv/ +/.idea/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e9919fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM python:alpine +RUN apk update + + +ENV APP_HOST='0.0.0.0' \ +APP_PORT='8080' \ +APP_DEBUG_MODE=True + + + +WORKDIR /app + +COPY . . + +RUN pip install -r requirements.txt + +ENTRYPOINT ["python","-m", "server.app"] \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..abf2862 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask==3.0.3 \ No newline at end of file diff --git a/server/__init__.py b/server/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/__pycache__/__init__.cpython-312.pyc b/server/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf11ffa0a54fc91e29dc4c1e0bf7897095ed3eff GIT binary patch literal 120 zcmX@j%ge<81V++J(m?cM5P=Rpvj9b=GgLBYGWxA#C}INgK7-W!64y^GD9|rXEhML&8CSFHQ3M~LGaR4NWr6sptdFlH9=RD9J(agNt$&3nB5d22n`1dIpY;qkpU-}l}(%zTf>qadR5?PKjV z0{AV9QK;wOBri_7V1R*4uuushi9=?{!XZ$2qBgHj&`#cx{F`YgqgnrOHc4}Fpa0NYc>WyO#(@t6 z?Wy)uCVC{x4C2aTv+S)15Psy?wMJc_1f%ta=ToLv%ocT7!}dKM(RHibuyvhB9u$ju zzVJc|P_gh_d!KlxKfkbnDoNq9%ZYP zWvgd<8Iirzd2fOPrbvRYVV5l`Y~Zr%@^B#Lu^MwM-KjKb)#sSCY>w;H{{$yO1E<&K z1$RCeEn(JepGNLkj?psdeKsQ~@~e1nMLNa^p&=xPaB~QE55uvI{5xk29{^sDcA^8A z?!olt>OQ1@;n>ETA9&`FB;VtGa^rxg>$y&DGto_LrMl^@^oMBw>g_MLcIS5HcC$O# nuc`i>Cwtnffwt7smIhj-r&acVm!uZOC*_o;78GUXl@x&t1zN|PSWr+5(xC85K_AH0FHS8gOD)oeD~!)g%u7s9 zEz&Efyd{ijPH_;SOll?+9kKvhNTK;jpNO>TZlX-=wL5f6|Ha#%4hkodsN$jEq?LFqFSBcl>nIRKE; BPp<#~ literal 0 HcmV?d00001 diff --git a/server/__pycache__/blueprints.cpython-312.pyc b/server/__pycache__/blueprints.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0dc4662e18a1638d6b51ff8eead7797e1fa371de GIT binary patch literal 365 zcmX@j%ge<81p9cGq(uVh#~=<2FhLogg@BCd3@HpLj5!QZ3@J=43{i}gjGD|ZK??km z8KLSx6f+cmb^gWzW-Mn(;=asYkoO4$Ga literal 0 HcmV?d00001 diff --git a/server/__pycache__/config.cpython-312.pyc b/server/__pycache__/config.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..085be2d1da3011a46964991213217da229102dec GIT binary patch literal 501 zcmX@j%ge<81pI1C)20IH#~=<2us|7~6@ZNC3@HpLj5!QZ3``8}3@J=43@Oa3nII~n z7%LeySzdxTe#sCa2nm&E_?!mhPiIJFh+<4(h+;}*&f-8;24SZ#N&*>CtT<$uz_M&O zWSPOT?3FBnTSONY)A-DKIVlJ*uq3-d%{w}V5njE({ z;^XrYb5rBvZ*j%P=jNxB=788d@$rSFi8)Xiru^bt?5TNWnML_|MXW$)7O{Z{b|A5m z;WLnA_$8{JSWuu}oLW?tTBM&0c7a|&Wf3S4!2~mqQLGCjS{QEd^7lt|M$O>5$gAAo zfyNUSoo+SJ>Vll!MPdC$zal=Eeodw#ZWz0W7sLWf@dH`EIBX#9wkr|&>=B1=oB!hS`zzk%7@Mk?BF`c1?Aq!a+s;UHL3&U!tEF(iD&_F*;rdvWq zsp*-;C8gFx+5azs@3ckwt2b=~WiR&p tP*o8-kod)6lbfGXnv-f*!~^7loL0;WBt9@RGBVy}Q2xxq$fyKX4giekQFH(R literal 0 HcmV?d00001 diff --git a/server/app.py b/server/app.py new file mode 100644 index 0000000..8006d08 --- /dev/null +++ b/server/app.py @@ -0,0 +1,9 @@ +from flask import Flask +from server.config import Config +from server.register_blueprints import register_blueprints +app = Flask(__name__) +app.config.from_object(Config) + +if __name__ == '__main__': + register_blueprints(app) + app.run(host=app.config.get('APP_HOST'), port=app.config.get('APP_PORT'), debug=app.config.get('APP_DEBUG_MODE')) diff --git a/server/blueprints/__init__.py b/server/blueprints/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/blueprints/__pycache__/__init__.cpython-312.pyc b/server/blueprints/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0fb06e4dcf1730f7dcbd39a33e04aa44d44de60c GIT binary patch literal 131 zcmX@j%ge<81kt+}r-A6lAOanHW&w&!XQ*V*Wb|9fP{ah}eFmxdrKF!&P@rF&T2z)= zq@R>inp#klnO9P*A0MBYmst`YuUAm{i^C>2KczG$)vkyYsD%-Ti$RQ!%#4hTMa)1J E0O;Kv9smFU literal 0 HcmV?d00001 diff --git a/server/blueprints/__pycache__/blueprints.cpython-312.pyc b/server/blueprints/__pycache__/blueprints.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ade2390bcad9e96001b0d41c19beb44056151482 GIT binary patch literal 374 zcmX@j%ge<81poM!q@@7q#~=<2FhLog#ej_I3@HpLj5!Rsj8Tk?3@J=43{gy#%$h7O zL5egPZ?R_PrKDCQGeY%%C}t@BtOsOFXQ*MwLY4)o0D=;jEexxnvWyIsKm+|WnQjRc zrKV>Vm!uZOC*_o;78GUXl@x&t1zN|PSWr+5(xC85MIXr4FHS8gOD)oeD=bE0>J?Pp z62>&ExQGL20LcDg0U*)9aD#>YI*Zgr7O6R=S6LK41H~BpG?{M+APm(5`x5L3u;!Hv vMVvrYMeIQ07l%!5eoARhs$CHekPC8LF)xt#z|6?Vc$Y!xGZQ1D5?DC^IABp@ literal 0 HcmV?d00001 diff --git a/server/blueprints/__pycache__/index.cpython-312.pyc b/server/blueprints/__pycache__/index.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ceafc8934c86dd67469e72562a897eb4789998a2 GIT binary patch literal 894 zcmZ`%&5IK;6i+gp>9o63-4*<3)$L(HMzDhlRb*K~#A6Tct(T$gq;}TygUocbvO)zx zL6N=bf8a{}N5o5^o`Ry{skcgRJ^7NEsVl6HB=05fy}aM=C7&%Ti$G3)df$AF5&9)J ziKJp<{sxS<$U`1xsEw<*O{xSVk9Zo>+No*^BZ4UQQdA$2D5q*rWA{XI(O>Q9Bd8+9 zGoGVSWTLA1pXl^5+B_1S8D#A2ROZ@5WbUv&?Qy>oiu7*K?fA{XRD!UvIQf8vZoL-x z4Yx&WENltg?|Ag_0y~YkvQm<#26KK57T}4)7$cx02?8HKMWKvRvX7GU9b{`2VM2Y% zJ2f_ysW#yTC@wDs97a?RRpPC)q{P_A#F+?P0pP3P4&-wbi`)VwR_g-_ zBW8CBj#NkyjD+3C>xcc(tx3K-wr(6{$mM^k*jb@BSuJ?TB^OmroRQu18#E|Iop$4W z1j}^YPOVK{m&-;9op<~2Rq|gwD}E{ zf0}Ctm)_l+n43d=W+0M&QFvB(xii6QzX`#GxrWI4Oj-2O Cs!xXi literal 0 HcmV?d00001 diff --git a/server/blueprints/index.py b/server/blueprints/index.py new file mode 100644 index 0000000..21eee47 --- /dev/null +++ b/server/blueprints/index.py @@ -0,0 +1,15 @@ +from flask import Blueprint, jsonify +from ..services.health_service import get_basic_health + +index = Blueprint('index', __name__) + + +@index.route("/") +def hello_world(): + health = {"internal": get_basic_health(1)} + return jsonify(health) + +@index.route("/level/") +def byebye_world(level): + health = {"internal": get_basic_health(int(level))} + return jsonify(health) \ No newline at end of file diff --git a/server/config.py b/server/config.py new file mode 100644 index 0000000..8f40cd9 --- /dev/null +++ b/server/config.py @@ -0,0 +1,6 @@ +import os + +class Config: + APP_HOST=os.environ['APP_HOST'] + APP_PORT=os.environ['APP_PORT'] + APP_DEBUG_MODE=os.environ['APP_DEBUG_MODE'] \ No newline at end of file diff --git a/server/dev_utils/__init__.py b/server/dev_utils/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/helpers/__init__.py b/server/helpers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/register_blueprints.py b/server/register_blueprints.py new file mode 100644 index 0000000..f3b795d --- /dev/null +++ b/server/register_blueprints.py @@ -0,0 +1,4 @@ +from .blueprints.index import index + +def register_blueprints(app): + app.register_blueprint(index) diff --git a/server/services/__init__.py b/server/services/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/services/__pycache__/__init__.cpython-312.pyc b/server/services/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ed9bf3913198e0240e294b62f1f7f271632fd375 GIT binary patch literal 129 zcmX@j%ge<81m?RJr-A6lAOanHW&w&!XQ*V*Wb|9fP{ah}eFmxdrJ$c!P@rF&T2z)= z1g0{RQ;YTE<1_OzOXB183Mzkb*yQG?l;)(`6|n*}FamKgi1Cq`k&&^88OQBb5Qg`Q69oc=QDWg)7~>Uif56yiO+#lx&f7&UoIrN>NH7+L*qYc$VPRo` zzs2V4$hKB?mtaNZ> dict: + if level == 1: + return {"status": "ok"} + return {"status": "ok", "services": "ok"} \ No newline at end of file diff --git a/server/tests/__init__.py b/server/tests/__init__.py new file mode 100644 index 0000000..e69de29