first commit
This commit is contained in:
19
Dockerfile
Executable file
19
Dockerfile
Executable file
@@ -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
|
||||
|
||||
|
||||
BIN
__pycache__/main.cpython-312.pyc
Normal file
BIN
__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
BIN
app/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/database.cpython-312.pyc
Normal file
BIN
app/__pycache__/database.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
21
app/database.py
Normal file
21
app/database.py
Normal file
@@ -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)
|
||||
13
app/dependencies.py
Normal file
13
app/dependencies.py
Normal file
@@ -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")
|
||||
0
app/internal/__init__.py
Normal file
0
app/internal/__init__.py
Normal file
0
app/internal/admin.py
Normal file
0
app/internal/admin.py
Normal file
21
app/main.py
Normal file
21
app/main.py
Normal file
@@ -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"}
|
||||
|
||||
|
||||
0
app/models/__init__.py
Normal file
0
app/models/__init__.py
Normal file
BIN
app/models/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/models/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/models/__pycache__/delivery.cpython-312.pyc
Normal file
BIN
app/models/__pycache__/delivery.cpython-312.pyc
Normal file
Binary file not shown.
52
app/models/delivery.py
Normal file
52
app/models/delivery.py
Normal file
@@ -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))
|
||||
|
||||
|
||||
0
app/routers/__init__.py
Normal file
0
app/routers/__init__.py
Normal file
BIN
app/routers/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/routers/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/routers/__pycache__/command.cpython-312.pyc
Normal file
BIN
app/routers/__pycache__/command.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/routers/__pycache__/printstatus.cpython-312.pyc
Normal file
BIN
app/routers/__pycache__/printstatus.cpython-312.pyc
Normal file
Binary file not shown.
16
app/routers/command.py
Normal file
16
app/routers/command.py
Normal file
@@ -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}
|
||||
10
app/routers/printstatus.py
Normal file
10
app/routers/printstatus.py
Normal file
@@ -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"}
|
||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
fastapi
|
||||
uvicorn[standard]
|
||||
psycopg2-binary
|
||||
sqlalchemy
|
||||
Reference in New Issue
Block a user