Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ea2ba9f15 | |||
| 3ad838fd2c |
@@ -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()
|
|
||||||
@@ -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 +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>
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
from fastapi import FastAPI, Request
|
from fastapi import FastAPI, Request
|
||||||
from fastapi.responses import HTMLResponse
|
from datetime import datetime, timezone
|
||||||
import uvicorn
|
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
@app.get("/", response_class=HTMLResponse)
|
@app.get("/")
|
||||||
def read_root():
|
async def read_root(request: Request):
|
||||||
with open("index.html", "r") as f:
|
client_host = request.client.host
|
||||||
return f.read()
|
return {
|
||||||
|
"message": "ハローワールド!!",
|
||||||
if __name__ == "__main__":
|
"client_ip": client_host,
|
||||||
uvicorn.run(app, host="0.0.0.0", port=8000)
|
"current_time_utc": datetime.now(timezone.utc).isoformat()
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user