File size: 1,012 Bytes
7b7bdab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
import os
from django.core.asgi import get_asgi_application
from fastapi import FastAPI, Request
from starlette.middleware.cors import CORSMiddleware
print("Starting minimal ASGI app...")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
try:
application = get_asgi_application()
print("✓ Django ASGI application created successfully")
except Exception as e:
print(f"✗ Django ASGI application creation failed: {e}")
application = None
app = FastAPI()
print("✓ FastAPI application created successfully")
# ミドルウェアの設定
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
print("✓ CORS middleware added successfully")
@app.get("/")
def read_root():
return {"message": "FastAPI + Django app is working!"}
@app.get("/health")
def health_check():
return {"status": "ok"}
print("✓ Basic routes defined successfully")
print("ASGI app setup complete!")
|