Skip to content

Commit

Permalink
Added Schemas, main database, main (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanAEckelberg authored Sep 9, 2023
1 parent f0fe075 commit 50f297b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions game/utils/validation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import parsec
import re

from game.config import ALLOWED_MODULES
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file added server/crud/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions server/database.py
Original file line number Diff line number Diff line change
@@ -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)
23 changes: 23 additions & 0 deletions server/main.py
Original file line number Diff line number Diff line change
@@ -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"}
Empty file added server/schemas/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions server/schemas/submission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from pydantic import BaseModel

class SubmissionBase(BaseModel):
...

0 comments on commit 50f297b

Please sign in to comment.