Compare commits

2 Commits

Author SHA1 Message Date
MyAgent 1ea2ba9f15 Add UTC current time to response 2026-05-17 08:06:01 +00:00
Agent 3ad838fd2c Initial commit: FastAPI Hello World API 2026-05-17 07:28:41 +00:00
5 changed files with 9 additions and 36 deletions
-7
View File
@@ -1,7 +0,0 @@
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()
-12
View File
@@ -1,12 +0,0 @@
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
-1
View File
@@ -1 +0,0 @@
<!DOCTYPE html><html><head><script src="https://cdn.tailwindcss.com"></script></head><body class="bg-yellow-50 p-10"><h1 class="text-2xl font-bold">旅行地のノート</h1></body></html>
+9 -9
View File
@@ -1,13 +1,13 @@
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse
import uvicorn
from datetime import datetime, timezone
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)
@app.get("/")
async def read_root(request: Request):
client_host = request.client.host
return {
"message": "ハローワールド!!",
"client_ip": client_host,
"current_time_utc": datetime.now(timezone.utc).isoformat()
}
-7
View File
@@ -1,7 +0,0 @@
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)