From 203518ac669b19bb2dc2e3f57bb1c59eec136a17 Mon Sep 17 00:00:00 2001 From: Agent Date: Sun, 17 May 2026 10:04:27 +0000 Subject: [PATCH] Final push: Correct directory structure and content --- database.py | 7 +++++++ docker-compose.yaml | 12 ++++++++++++ index.html | 1 + main.py | 13 +++++++++++++ models.py | 7 +++++++ 5 files changed, 40 insertions(+) create mode 100644 database.py create mode 100644 docker-compose.yaml create mode 100644 index.html create mode 100644 main.py create mode 100644 models.py diff --git a/database.py b/database.py new file mode 100644 index 0000000..10960e3 --- /dev/null +++ b/database.py @@ -0,0 +1,7 @@ +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker, declarative_base + +SQLALCHEMY_DATABASE_URL = "postgresql://user:pass@db:5432/notes" +engine = create_engine(SQLALCHEMY_DATABASE_URL) +SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) +Base = declarative_base() \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d5650af --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: "3.8" +services: + app: + build: . + ports: ["8000:8000"] + depends_on: [db] + db: + image: postgres:13 + environment: + POSTGRES_USER: user + POSTGRES_PASSWORD: pass + POSTGRES_DB: notes \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..ff86036 --- /dev/null +++ b/index.html @@ -0,0 +1 @@ +

旅行地のノート

\ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..862fd4a --- /dev/null +++ b/main.py @@ -0,0 +1,13 @@ +from fastapi import FastAPI, Request +from fastapi.responses import HTMLResponse +import uvicorn + +app = FastAPI() + +@app.get("/", response_class=HTMLResponse) +def read_root(): + with open("index.html", "r") as f: + return f.read() + +if __name__ == "__main__": + uvicorn.run(app, host="0.0.0.0", port=8000) \ No newline at end of file diff --git a/models.py b/models.py new file mode 100644 index 0000000..37c749f --- /dev/null +++ b/models.py @@ -0,0 +1,7 @@ +from sqlalchemy import Column, Integer, String +from database import Base + +class Note(Base): + __tablename__ = "notes" + id = Column(Integer, primary_key=True, index=True) + content = Column(String) \ No newline at end of file