From de448a35d14d581950b03c6dfca75ad39d577552 Mon Sep 17 00:00:00 2001 From: Anekdotin Date: Tue, 26 Mar 2024 13:17:04 -0400 Subject: [PATCH] first commit --- Dockerfile | 19 +++++++ __pycache__/main.cpython-312.pyc | Bin 0 -> 1234 bytes app/__init__.py | 0 app/__pycache__/__init__.cpython-312.pyc | Bin 0 -> 117 bytes app/__pycache__/database.cpython-312.pyc | Bin 0 -> 776 bytes app/__pycache__/main.cpython-312.pyc | Bin 0 -> 622 bytes app/database.py | 21 +++++++ app/dependencies.py | 13 +++++ app/internal/__init__.py | 0 app/internal/admin.py | 0 app/main.py | 21 +++++++ app/models/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 124 bytes .../__pycache__/delivery.cpython-312.pyc | Bin 0 -> 2415 bytes app/models/delivery.py | 52 ++++++++++++++++++ app/routers/__init__.py | 0 .../__pycache__/__init__.cpython-312.pyc | Bin 0 -> 125 bytes .../__pycache__/command.cpython-312.pyc | Bin 0 -> 820 bytes .../__pycache__/printstatus.cpython-312.pyc | Bin 0 -> 581 bytes app/routers/command.py | 16 ++++++ app/routers/printstatus.py | 10 ++++ requirements.txt | 4 ++ 22 files changed, 156 insertions(+) create mode 100755 Dockerfile create mode 100644 __pycache__/main.cpython-312.pyc create mode 100644 app/__init__.py create mode 100644 app/__pycache__/__init__.cpython-312.pyc create mode 100644 app/__pycache__/database.cpython-312.pyc create mode 100644 app/__pycache__/main.cpython-312.pyc create mode 100644 app/database.py create mode 100644 app/dependencies.py create mode 100644 app/internal/__init__.py create mode 100644 app/internal/admin.py create mode 100644 app/main.py create mode 100644 app/models/__init__.py create mode 100644 app/models/__pycache__/__init__.cpython-312.pyc create mode 100644 app/models/__pycache__/delivery.cpython-312.pyc create mode 100644 app/models/delivery.py create mode 100644 app/routers/__init__.py create mode 100644 app/routers/__pycache__/__init__.cpython-312.pyc create mode 100644 app/routers/__pycache__/command.cpython-312.pyc create mode 100644 app/routers/__pycache__/printstatus.cpython-312.pyc create mode 100644 app/routers/command.py create mode 100644 app/routers/printstatus.py create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100755 index 0000000..c6164f9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM python:3.12-bullseye + +ENV PYTHONFAULTHANDLER=1 + +ENV PYTHONUNBUFFERED=1 + +RUN mkdir -p /app + +COPY requirements.txt /app + +WORKDIR /app + +RUN pip3 install -r requirements.txt + +EXPOSE 8000 + +COPY . /app + + diff --git a/__pycache__/main.cpython-312.pyc b/__pycache__/main.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..46211945d74c0a3040b7f495525faf988655e2d9 GIT binary patch literal 1234 zcmaJ=OKTKC5U!q?o!9PcvRTc881XHuV!SCR0X+l-5iy7`m(bbnB(wI+tUa?zZW|OL zc!?)H_yd&q2gIM?B_V-q8iI;=5HFE<%E|88-55x;p}Xs=ss5_J>Y7iU=Ykv`e`?cj zHGpplbcfwBw%;ItS3rOu1|jkh0-_O}X`$}xq2U`612I@GG<`F(bIb~D-_C54Iic&j znQcis@8=O{Kuua$lDum8p2Yd3HUPg!i?yR2uxG0s-vc@(^|~Axr%S!}cGu&VBx`Ax zwNE0ni^{ZIs~o_m*Us(tb{P@;v59KaGE?~ z!tUAvgu~)0X0!66Fv2-96So-o8T0yJi@5Q zJl#Q~)xCv~9SXXf+p1}0M2YgtC$q74!QCzQ&hB$~W z*5`yHg_B7h$0=7mc0$g?lS>o66v~Samh&Ua#t1(mJ$EWY!kU)##Pxuytis}PBc(jy zIf=M>F5yc3m{n(KIL9sJDE)O@Y*&}7|40<~_+uV&M^PvlLT_*;%yz6WZYc3~NK>pz zA>7VGVa9|t(S96ZbzVv6Qkf_QQI$0am7>(`gxTHOM}9;IJF7KH{t9iod4?dFD9$baMRqd23D=1rqKdp!JGHi zVQ>WoU-z%Uu?@HX_4t~5vT1F&r5BZ^_0{yA22K47=n9`{O z3mc5AC>L%Mlt(8E7Nl4La}rvbuOME1*G1z z4+Q;6qxwth4JiGPQ=HKanruf2Rf6&4(F2vrf(j9(3Byk*SA3SxFvc8b(GK0%#DYrH zO+~iNsdyGkcZwClLOf47dEvM2tTtP>*P5;7>W!PyqL_tgw02&#wIw2472*kIRJuKp zBkrl0q}f(=rAu&zCw%jAkA+7#J$T>(u?UmzN|Lsix-Ld{5BwjW3Vy?%VThL46gmK zX9wY4XSXw|E{*(}e!Tj~pC5VtAK!6G1LNo%K($xmz*`#FhiKvLmG`$k?0iP+1Lqr> jd)XK`hfeLlSsa)nVD9<5{#Q`{1nO@VzJSa8l4|)6XfV*9 literal 0 HcmV?d00001 diff --git a/app/__pycache__/main.cpython-312.pyc b/app/__pycache__/main.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9a23e4e5a86ba55f472a9eb9557131e6a99dcf61 GIT binary patch literal 622 zcmah`Jxc>Y5S`h*GbS;I8Zm_*g`jXCT3RRp8_^~Rf`K%0WLG)4%N=`{!cI}pQY(Lh z_(udA1wq-yfLK@v38_rw?wK={xUf5K-p;(4oxLv4Y~1UTOI!)qot4-2Wtz;b$M4ZIZH;txXjBg^HpTQ-sTP`Hgaik-L_$xJ=)eW$^CxLhA7f_fu>9!XbE zOpOB>ad8K1T9M`^_q;%w)j)Xc28532stvu-WhV@i?K^H`DLj%{!5y|If*=-pNV@q* zgJWoo6fdg}`I!e}M&uP!v2!xBubOm1SLn(zuf&!_(2Ti=grOK=YMLrqT5hB6H5pgZ z`d$w8Ej{2rm6EO!VKJhzdc$jez?vQ}iwWiGZ-{o)(WZ#_4pXnN*s&mEow~=g1@sxl xA7T7*^|?6zSe$=?g_mD$<+^-TeuBC7Fc9;+bW*w~o=$fN;%t`!u@aQj{RZn@e5?Qf literal 0 HcmV?d00001 diff --git a/app/database.py b/app/database.py new file mode 100644 index 0000000..0242857 --- /dev/null +++ b/app/database.py @@ -0,0 +1,21 @@ +from sqlalchemy import create_engine +from sqlalchemy.engine import URL +from sqlalchemy.orm import sessionmaker +from sqlalchemy.orm import declarative_base + +url = URL.create( + drivername="postgresql", + username="postgres", + password="password", + host="192.168.1.204", + database="eamco", + port=5432 +) + +engine = create_engine(url) + +Session = sessionmaker(autocommit=False, autoflush=False, bind=engine) +session = Session() + +Base = declarative_base() +Base.metadata.create_all(engine) \ No newline at end of file diff --git a/app/dependencies.py b/app/dependencies.py new file mode 100644 index 0000000..49d6ead --- /dev/null +++ b/app/dependencies.py @@ -0,0 +1,13 @@ +from typing import Annotated + +from fastapi import Header, HTTPException + + +async def get_token_header(x_token: Annotated[str, Header()]): + if x_token != "fake-super-secret-token": + raise HTTPException(status_code=400, detail="X-Token header invalid") + + +async def get_query_token(token: str): + if token != "jessica": + raise HTTPException(status_code=400, detail="No Jessica token provided") \ No newline at end of file diff --git a/app/internal/__init__.py b/app/internal/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/internal/admin.py b/app/internal/admin.py new file mode 100644 index 0000000..e69de29 diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..24a1093 --- /dev/null +++ b/app/main.py @@ -0,0 +1,21 @@ + +from fastapi import FastAPI +from app.routers import printstatus, command + + + + + + +app = FastAPI() + +app.include_router(printstatus.router) +app.include_router(command.router) + + + +@app.get("/") +def read_root(): + return {"Hello": "World"} + + diff --git a/app/models/__init__.py b/app/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/models/__pycache__/__init__.cpython-312.pyc b/app/models/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1e1a8d4929bbd6f16a359a6b636d32a8babf903b GIT binary patch literal 124 zcmX@j%ge<81gpO?rGe^KjSG(4J^Kq6>WR23*8;SrI9mPSR|%WCnAlP$a6&Fq@s zsv@q$p%Ohr$^oLixZ+|IB=|piiL@Nzk$OPAlv}HSP&svGUlWx2FTZxRXXP` zN(L;tZrqXV&v_0G6Ymch$OtT8gb-kbaEO5%jDQgNg`aY})Gv92sJp()dYGq}yfF~* z*Zi*#@4zJjF6ztsUm@9nOHmF6zJzoe?rOss&sI0!L2NhVMjd$SX_M}4!+oB1cGp!T zCkAsrobW))$LF8MeIG);T^A%;*a43n^ff|;iGN%7{%oMc+8)+Nl$pvG4TKTnC!q6JnrLOj(23IIDE~!n+pAwm z`Mf$!2U?Zndh!64q>5rL7f#}sD3&D^iXu*kqN;(4Lgy(_T(3xq$D~Eklx``|g^2bK zw>^YpfRn|FVQMNwq6`pED4Y&fr~>W|pacMdhS4HmY8z$T6$lt6=^;23;2&ijXI3Re z(aMIXApj8sI3LiGaT@}$q#>~+D+;1L6ZiPyUap8jCQzVabivP~NF7!T6r($$&6p(4 zES9wmoZ47}<-lc^g93{vPDT6ST^$xp5DmMJ72S zXI6wQJ9cq4h|q+p4iO0oK}35d?gp})88aP7F9paclj}1swoYJK#J$2En z>JVpqRFn{)&eKK7SQ8N}%J2@^d@n$>tVH5S(W($qksfcYBqPIg>Vf!m#T3b3>Cq7s zi)#{Eg`%Wt6;ftNQ!^#S+f=e7mwoVrIUvC^?}le2U3XqmT2L`&{8UZrRg@+Y&Op;| zJR^<%KC_>ls4cyWXSVqLu_OEA$M%QDUi0C^c+Yeq?904lLEqpV;HFF8P^t*3M26GB><)r9NjZ+POk)xk)TcY=2!_eA$2K(amkG zcD*@zw0_gl_PAl!%&o?_Rkrgd_qbfsmw7MTH@H))P||i`*B)$Hx0%TjUP|O8Vx|S9IoBKSyToVrSjXbRJzGkp3euCdu%3m}S|wp%6R%mLbCd9o|G4 VcJvQs^mX(&TlmF%!;p_-=|4OBgG2xT literal 0 HcmV?d00001 diff --git a/app/models/delivery.py b/app/models/delivery.py new file mode 100644 index 0000000..6696629 --- /dev/null +++ b/app/models/delivery.py @@ -0,0 +1,52 @@ +from sqlalchemy import Column, Integer,\ + Integer, DECIMAL, Text,\ + VARCHAR, TIMESTAMP, Date +from datetime import datetime +from app.database import Base + + +class Delivery(Base): + __tablename__ = "delivery_delivery" + + id = Column(Integer, + primary_key=True, + autoincrement=True, + unique=False) + + customer_id = Column(Integer) + customer_name = Column(VARCHAR(1000)) + customer_address = Column(VARCHAR(1000)) + customer_town = Column(VARCHAR(140)) + customer_state = Column(VARCHAR(140)) + customer_zip = Column(Integer) + + gallons_ordered = Column(Integer) + customer_asked_for_fill = Column(Integer) + gallons_delivered =Column(DECIMAL(50, 2)) + customer_filled = Column(Integer) + + delivery_status = Column(Integer) + when_ordered = Column(TIMESTAMP(), default=datetime.utcnow()) + when_delivered = Column(TIMESTAMP(), default=None) + expected_delivery_date = Column(Date(), default=None) + automatic = Column(Integer) + oil_id = Column(Integer) + supplier_price = Column(DECIMAL(50, 2)) + customer_price = Column(DECIMAL(50, 2)) + customer_temperature = Column(DECIMAL(50, 2)) + dispatcher_notes = Column(Text()) + prime = Column(Integer) + same_day = Column(Integer) + payment_type = Column(Integer) + payment_card_id = Column(Integer) + cash_recieved = Column(DECIMAL(50, 2)) + + driver_employee_id = Column(Integer) + driver_first_name = Column(VARCHAR(140)) + driver_last_name = Column(VARCHAR(140)) + + pre_charge_amount = Column(DECIMAL(50, 2)) + total_price = Column(DECIMAL(50, 2)) + final_price = Column(DECIMAL(50, 2)) + + diff --git a/app/routers/__init__.py b/app/routers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/routers/__pycache__/__init__.cpython-312.pyc b/app/routers/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6d946626f2bdeab2fcdd832e13f7bbcb860bc49b GIT binary patch literal 125 zcmX@j%ge<81mB-ArGez^4ZBeOK zu%4_?=+%Q4iT)*CT6!=H6c2jPTT49Ho}AfaQ3vMD_vX#K`Mz)Wv*Xwx$NM8(_YuH1 zm1M&lg8nlJwt)aaEeMf^LhRvC^E9OPa4Q$;o}OZ@WrU_@BEUcq$q~JQh(SzZ1t>rt z^IdJw(X*)4EM?F9U5VY59Mm9%m(U$R@a&Zl*ZHY3R}=ZU#ap+dPC}V5=V?sagbU~9 z($eCMHr^r<0{-^30s+ctzNZ`s7}a(2%pTJnpD_=VkZ-zt`ZqRea;TcD5eu zSrcEZsaQ6~PBB$sx(s4O zl9(ob;@|f<9gr`ntuP|A#iwORKixozF<>gR22E00AD}Or08@X`v2|5m>a^%Jc1EU3 zB(KVFpdp05!t5^0?!)9hoI5nYF7*m0dvFU=*|XG}`@Q$(z4^V5ug#{9wEQ{6@wv9YOmHRc+?mGO z`G6>*kf0PoNO6c$5)wcdF`$@|0Z@zD)ZxJ4vpXX7&(LDltKf?6zom^4)DiXGq0u}M zI(vR6I5km+DDUCc(`WgxWJ0-*S-~w1Lw>~xN+2e(>{K5xO$EOZcPcoOO;pk`3Iy{kxu{s literal 0 HcmV?d00001 diff --git a/app/routers/command.py b/app/routers/command.py new file mode 100644 index 0000000..630dfc9 --- /dev/null +++ b/app/routers/command.py @@ -0,0 +1,16 @@ +from fastapi import APIRouter, Depends, HTTPException +from app.database import session +from app.models.delivery import Delivery + + +router = APIRouter( + prefix="/command", + tags=["command"], + responses={404: {"description": "Not found"}}, +) + + +@router.get("/") +async def read_items(): + x = session.query(Delivery).first() + return {"x": x.id} \ No newline at end of file diff --git a/app/routers/printstatus.py b/app/routers/printstatus.py new file mode 100644 index 0000000..dab9e77 --- /dev/null +++ b/app/routers/printstatus.py @@ -0,0 +1,10 @@ +from fastapi import APIRouter, Depends, HTTPException + +router = APIRouter( + prefix="/status", + tags=["status"], + responses={404: {"description": "Not found"}}, +) +@router.get("/") +async def read_items(): + return {"Hello": "World"} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4e961b3 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +fastapi +uvicorn[standard] +psycopg2-binary +sqlalchemy \ No newline at end of file