commit d446b62ca8beb80b96c8ab51e0dec0fb8656c98f
Author: matejzeman <zeman339@gmail.com>
Date:   Mon Mar 21 23:57:18 2022 +0100

    re #9304 HelloWorld API for sending data defined in USBLog class. Returns simple sucess message

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7802556
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,267 @@
+# Created by https://www.toptal.com/developers/gitignore/api/python,pycharm
+# Edit at https://www.toptal.com/developers/gitignore?templates=python,pycharm
+
+### PyCharm ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+# User-specific stuff
+.idea/**/workspace.xml
+.idea/**/tasks.xml
+.idea/**/usage.statistics.xml
+.idea/**/dictionaries
+.idea/**/shelf
+
+# AWS User-specific
+.idea/**/aws.xml
+
+# Generated files
+.idea/**/contentModel.xml
+
+# Sensitive or high-churn files
+.idea/**/dataSources/
+.idea/**/dataSources.ids
+.idea/**/dataSources.local.xml
+.idea/**/sqlDataSources.xml
+.idea/**/dynamic.xml
+.idea/**/uiDesigner.xml
+.idea/**/dbnavigator.xml
+
+# Gradle
+.idea/**/gradle.xml
+.idea/**/libraries
+
+# Gradle and Maven with auto-import
+# When using Gradle or Maven with auto-import, you should exclude module files,
+# since they will be recreated, and may cause churn.  Uncomment if using
+# auto-import.
+# .idea/artifacts
+# .idea/compiler.xml
+# .idea/jarRepositories.xml
+# .idea/modules.xml
+# .idea/*.iml
+# .idea/modules
+# *.iml
+# *.ipr
+
+# CMake
+cmake-build-*/
+
+# Mongo Explorer plugin
+.idea/**/mongoSettings.xml
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Cursive Clojure plugin
+.idea/replstate.xml
+
+# SonarLint plugin
+.idea/sonarlint/
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+# Editor-based Rest Client
+.idea/httpRequests
+
+# Android studio 3.1+ serialized cache file
+.idea/caches/build_file_checksums.ser
+
+### PyCharm Patch ###
+# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
+
+# *.iml
+# modules.xml
+# .idea/misc.xml
+# *.ipr
+
+# Sonarlint plugin
+# https://plugins.jetbrains.com/plugin/7973-sonarlint
+.idea/**/sonarlint/
+
+# SonarQube Plugin
+# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
+.idea/**/sonarIssues.xml
+
+# Markdown Navigator plugin
+# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
+.idea/**/markdown-navigator.xml
+.idea/**/markdown-navigator-enh.xml
+.idea/**/markdown-navigator/
+
+# Cache file creation bug
+# See https://youtrack.jetbrains.com/issue/JBR-2257
+.idea/$CACHE_FILE$
+
+# CodeStream plugin
+# https://plugins.jetbrains.com/plugin/12206-codestream
+.idea/codestream.xml
+
+### Python ###
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+cover/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+.pybuilder/
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+#   For a library or package, you might want to ignore these files since the code is
+#   intended to run in multiple environments; otherwise, check them in:
+# .python-version
+
+# pipenv
+#   According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+#   However, in case of collaboration, if having platform-specific dependencies or dependencies
+#   having no cross-platform support, pipenv may install dependencies that don't work, or not
+#   install all needed dependencies.
+#Pipfile.lock
+
+# poetry
+#   Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
+#   This is especially recommended for binary packages to ensure reproducibility, and is more
+#   commonly ignored for libraries.
+#   https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
+#poetry.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
+
+# pytype static type analyzer
+.pytype/
+
+# Cython debug symbols
+cython_debug/
+
+# PyCharm
+#  JetBrains specific template is maintained in a separate JetBrains.gitignore that can
+#  be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
+#  and can be added to the global gitignore or merged into this file.  For a more nuclear
+#  option (not recommended) you can uncomment the following to ignore the entire idea folder.
+#.idea/
+
+# End of https://www.toptal.com/developers/gitignore/api/python,pycharm
diff --git a/server/sql_app/__init__.py b/server/sql_app/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/server/sql_app/crud.py b/server/sql_app/crud.py
deleted file mode 100644
index 7f68240..0000000
--- a/server/sql_app/crud.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from sqlalchemy.orm import Session
-
-from . import models, schemas
-
-
-def get_device(db: Session, device_id: int):
-    return db.query(models.Device).filter(models.Device.id == device_id).first()
-
-def get_devices(db: Session, skip: int = 0, limit: int = 100):
-    return db.query(models.Device).offset(skip).limit(limit).all()
-
-
-def create_device(db: Session, device: schemas.DeviceCreate):
-    db_device = models.Device(vendor_id=device.vendor_id, product_id=device.product_id)
-    db.add(db_device)
-    db.commit()
-    db.refresh(db_device)
-    return db_device
-
-
-def get_logs(db: Session, skip: int = 0, limit: int = 100):
-    return db.query(models.USBLog).offset(skip).limit(limit).all()
-
-def get_log(db: Session, device_id: int, skip: int=0, limit: int=100):
-    return db.query(models.USBLog).filter(models.USBLog.device_id == device_id).offset(skip).limit(limit).all()
-
-def create_device_logs(db: Session, item: schemas.USBLogCreate, dev_id: int):
-    db_log = models.USBLog(**item.dict(), device_id=dev_id)
-    db.add(db_log)
-    db.commit()
-    db.refresh(db_log)
-    return db_log
-
diff --git a/server/sql_app/database.py b/server/sql_app/database.py
deleted file mode 100644
index ed8aff6..0000000
--- a/server/sql_app/database.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from sqlalchemy import create_engine
-from sqlalchemy.ext.declarative import declarative_base
-from sqlalchemy.orm import sessionmaker
-
-SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db"
-
-engine = create_engine(
-    SQLALCHEMY_DATABASE_URL
-)
-SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
-
-Base = declarative_base()
-
diff --git a/server/sql_app/main.py b/server/sql_app/main.py
index 0c7037e..8642923 100644
--- a/server/sql_app/main.py
+++ b/server/sql_app/main.py
@@ -1,57 +1,28 @@
-from typing import List
-
-from fastapi import Depends, FastAPI, HTTPException
-from sqlalchemy.orm import Session
-
-from . import crud, models, schemas
-from .database import SessionLocal, engine
-
-models.Base.metadata.create_all(bind=engine)
-
+from fastapi import FastAPI
+import fastapi
+from pydantic import BaseModel
+from typing import Optional, List
 
 app = FastAPI()
-    
-# Dependency
-def get_db():
-    db = SessionLocal()
-    try:
-        yield db
-    finally:
-        db.close()
-
-
-@app.post("/device/", response_model=schemas.Device)
-def create_device(device: schemas.DeviceCreate, db: Session = Depends(get_db)):
-    return crud.create_device(db=db, device=device)
-
-@app.get("/devices/", response_model=List[schemas.Device])
-def read_devices(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
-    devices = crud.get_devices(db, skip=skip, limit=limit)
-    return devices
-
-
-@app.get("/device/{device_id}", response_model=schemas.Device)
-def read_device(device_id: int, db: Session = Depends(get_db)):
-    db_device = crud.get_device(db, device_id=device_id)
-    if db_device is None:
-        raise HTTPException(status_code=404, detail="Device not found")
-    return db_device
-
-
-@app.post("/api/v1/logs/{device_id}/", response_model=schemas.USBLog)
-def create_device_logs(device_id: int, log: schemas.USBLogCreate, db: Session = Depends(get_db)):
-    return crud.create_device_logs(db=db, item=log, dev_id=device_id)
-
-
-@app.get("/logs/", response_model=List[schemas.USBLog])
-def read_logs(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
-    items = crud.get_logs(db, skip=skip, limit=limit)
-    return items
-
-@app.get("/logs/{device_id}", response_model=List[schemas.USBLog])
-def read_log(device_id: int, db: Session = Depends(get_db)):
-    db_log = crud.get_log(db, device_id=device_id)
-    if db_log is None:
-        raise HTTPException(status_code=404, detail="Logs not found")
-    return db_log
 
+class Device(BaseModel):
+	vendor_id: int
+	product_id: int
+	serial_number: int
+
+class USBLog(BaseModel):
+	username: str
+	hostname: str
+	timestamp: str
+	device: Device
+	status:str
+
+@app.post("/api/v1/usb-logs/")
+async def root_post(usb_log: USBLog):
+	print(usb_log)
+	return {"message": "Sucess"}
+	
+@app.get("/")
+async def root_read():
+	print("Hello")
+	return {"message":"Hello World"}
diff --git a/server/sql_app/models.py b/server/sql_app/models.py
deleted file mode 100644
index 1b55526..0000000
--- a/server/sql_app/models.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from sqlalchemy import Boolean, Column, ForeignKey, Integer, String
-from sqlalchemy.orm import relationship
-
-from .database import Base
-
-
-class Device(Base):
-    __tablename__ = "usb_devices"
-
-    id = Column(Integer, primary_key=True, index=True)
-    vendor_id = Column(Integer, index=True, nullable=False)
-    product_id = Column(Integer, index=True, nullable=False)
-
-    logs = relationship("USBLog", back_populates="device")
-
-
-class USBLog(Base):
-    __tablename__ = "usb_logs"
-
-    id = Column(Integer, primary_key=True, index=True)
-    username = Column(String, index=True, nullable=False)
-    hostname = Column(String, index=True, nullable=False)
-    timestamp = Column(String, index=True, nullable=False)
-    status = Column(String, index=True, nullable=False)
-    device_id = Column(Integer, ForeignKey("usb_devices.id"))
-
-    device = relationship("Device", back_populates="logs")
-
diff --git a/server/sql_app/schemas.py b/server/sql_app/schemas.py
deleted file mode 100644
index b63185b..0000000
--- a/server/sql_app/schemas.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from typing import List, Optional
-
-from pydantic import BaseModel
-
-
-class USBLogBase(BaseModel):
-    username: str
-    hostname: str
-    timestamp: str
-    status: str
-
-
-class USBLogCreate(USBLogBase):
-    pass
-
-
-class USBLog(USBLogBase):
-    id: int
-    device_id: int
-
-    class Config:
-        orm_mode = True
-        
-class DeviceBase(BaseModel):
-    vendor_id: int
-    product_id: int
-
-
-class DeviceCreate(DeviceBase):
-    pass
-
-
-class Device(DeviceBase):
-    id: int
-    logs: List[USBLog] = []
-    class Config:
-        orm_mode = True
-
