Add Seismo Fleet Manager backend v0.1
Implemented FastAPI backend with SQLite database for tracking seismograph fleet status: - database.py: SQLAlchemy setup with SQLite - models.py: Emitter model with id, unit_type, last_seen, last_file, status, notes - routes.py: POST /emitters/report and GET /fleet/status endpoints - main.py: FastAPI app initialization with CORS support - requirements.txt: Dependencies (FastAPI, SQLAlchemy, uvicorn)
This commit is contained in:
18
models.py
Normal file
18
models.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from sqlalchemy import Column, String, DateTime
|
||||
from datetime import datetime
|
||||
from database import Base
|
||||
|
||||
|
||||
class Emitter(Base):
|
||||
"""Emitter model representing a seismograph unit in the fleet"""
|
||||
__tablename__ = "emitters"
|
||||
|
||||
id = Column(String, primary_key=True, index=True)
|
||||
unit_type = Column(String, nullable=False)
|
||||
last_seen = Column(DateTime, default=datetime.utcnow)
|
||||
last_file = Column(String, nullable=False)
|
||||
status = Column(String, nullable=False) # OK, Pending, Missing
|
||||
notes = Column(String, nullable=True)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Emitter(id={self.id}, type={self.unit_type}, status={self.status})>"
|
||||
Reference in New Issue
Block a user