initial
This commit is contained in:
6
reflex_ipad/api/__init__.py
Normal file
6
reflex_ipad/api/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from . import medicine
|
||||
from . import scan
|
||||
|
||||
def register_at(app):
|
||||
medicine.register_at(app)
|
||||
scan.register_at(app)
|
||||
13
reflex_ipad/api/medicine.py
Normal file
13
reflex_ipad/api/medicine.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import reflex as rx
|
||||
from reflex_ipad.models import *
|
||||
from sqlmodel import Field, Session, SQLModel, create_engine, select
|
||||
|
||||
async def medicine_scan(uuid: str):
|
||||
with rx.session() as session:
|
||||
statement = select(Medicine).where(Medicine.uuid == uuid)
|
||||
results = session.exec(statement)
|
||||
med = results.first()
|
||||
return med
|
||||
|
||||
def register_at(app):
|
||||
app.api.add_api_route("/medicine/scan/{uuid}", medicine_scan)
|
||||
17
reflex_ipad/api/scan.py
Normal file
17
reflex_ipad/api/scan.py
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import reflex as rx
|
||||
from reflex_ipad.models import *
|
||||
from sqlmodel import Field, Session, SQLModel, create_engine, select
|
||||
import time
|
||||
|
||||
async def scan(uuid: str):
|
||||
print(uuid)
|
||||
with rx.session() as session:
|
||||
scan = Scan(uuid=uuid, timestamp=time.time())
|
||||
session.add(scan)
|
||||
session.commit()
|
||||
return scan.as_dict()
|
||||
|
||||
def register_at(app):
|
||||
print("register scan")
|
||||
app.api.add_api_route("/scan/{uuid}", scan)
|
||||
Reference in New Issue
Block a user