From f8659cef1d96cc06ab4a1b1eabde6e6dd12634f8 Mon Sep 17 00:00:00 2001 From: Jean Eckelberg Date: Sat, 9 Sep 2023 00:35:13 -0500 Subject: [PATCH] Added Schemas, main database, main --- game/utils/validation.py | 1 + requirements.txt | 7 +++++++ server/crud/__init__.py | 0 server/database.py | 10 ++++++++++ server/main.py | 23 +++++++++++++++++++++++ server/schemas/__init__.py | 0 server/schemas/submission.py | 4 ++++ 7 files changed, 45 insertions(+) create mode 100644 server/crud/__init__.py create mode 100644 server/database.py create mode 100644 server/main.py create mode 100644 server/schemas/__init__.py create mode 100644 server/schemas/submission.py diff --git a/game/utils/validation.py b/game/utils/validation.py index e98bc1c..f88e421 100644 --- a/game/utils/validation.py +++ b/game/utils/validation.py @@ -1,3 +1,4 @@ +import parsec import re from game.config import ALLOWED_MODULES diff --git a/requirements.txt b/requirements.txt index 12a5e54..62d7a8e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,11 @@ opencv-python~=4.8.0.76 Sphinx~=7.0.1 Myst-Parser~=2.0.0 furo~=2023.7.26 +parsec~=3.15 +opencv-python~=4.8.0.76 +Sphinx~=7.0.1 +Myst-Parser~=2.0.0 +furo~=2023.7.26 SQLAlchemy~=2.0.2 +pydantic~=2.3.0 +fastapi~=0.103.1 diff --git a/server/crud/__init__.py b/server/crud/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/database.py b/server/database.py new file mode 100644 index 0000000..1b60de3 --- /dev/null +++ b/server/database.py @@ -0,0 +1,10 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker + +DB_URL = 'sqlite:///./byte_server.db' + +engine = create_engine( + DB_URL, connect_args={'check_same_thread': False} +) + +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/server/main.py b/server/main.py new file mode 100644 index 0000000..cb912fe --- /dev/null +++ b/server/main.py @@ -0,0 +1,23 @@ +from fastapi import FastAPI, HTTPException, Depends +from sqlalchemy.orm import Session +from models.base import Base +from database import SessionLocal, engine + +Base.metadata.create_all(bind=engine) + +app = FastAPI() + + +def get_db(): + db = SessionLocal() + try: + yield db + finally: + db.close() + + +# API + +@app.get("/") +def root(): + return {"message": "Hello World"} \ No newline at end of file diff --git a/server/schemas/__init__.py b/server/schemas/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/server/schemas/submission.py b/server/schemas/submission.py new file mode 100644 index 0000000..c7d6107 --- /dev/null +++ b/server/schemas/submission.py @@ -0,0 +1,4 @@ +from pydantic import BaseModel + +class SubmissionBase(BaseModel): + ... \ No newline at end of file