rideshare-api / app /main.py
Sherry245's picture
Add gradient landing page at /
b9d1669
Raw History Blame Contribute Delete
3.03 kB
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import HTMLResponse
from app.api.v1 import rides, drivers, payments, users
from app.websockets import routes as ws_routes
app = FastAPI(title='RideShare API', version='1.0.0')
app.add_middleware(
CORSMiddleware,
allow_origins=['*'],
allow_methods=['*'],
allow_headers=['*'],
)
app.include_router(rides.router, prefix='/api/v1/rides', tags=['rides'])
app.include_router(drivers.router, prefix='/api/v1/drivers', tags=['drivers'])
app.include_router(payments.router, prefix='/api/v1/payments', tags=['payments'])
app.include_router(users.router, prefix='/api/v1/users', tags=['users'])
app.include_router(ws_routes.router)
@app.get('/health')
async def health():
return {'status': 'ok'}
_LANDING_HTML = """<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>RideShare API</title>
<style>
*{box-sizing:border-box;margin:0;padding:0}
body{
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
min-height:100vh;display:grid;place-items:center;
background:linear-gradient(135deg,#0f172a 0%,#0f766e 100%);
color:#f1f5f9;padding:24px;
}
.card{
max-width:560px;width:100%;
background:rgba(255,255,255,.05);backdrop-filter:blur(20px);
border:1px solid rgba(255,255,255,.12);border-radius:24px;
padding:40px;text-align:center;
}
.emoji{font-size:64px;line-height:1}
h1{font-size:28px;margin:16px 0 8px;font-weight:800}
.tag{
display:inline-block;padding:4px 12px;border-radius:999px;
background:#10b981;color:#022c22;font-size:12px;font-weight:700;
letter-spacing:.05em;text-transform:uppercase;margin-bottom:20px;
}
p{color:#cbd5e1;line-height:1.6;margin-bottom:16px}
.links{display:flex;gap:12px;justify-content:center;flex-wrap:wrap;margin-top:24px}
a{
color:#a7f3d0;text-decoration:none;font-weight:600;
padding:10px 18px;border-radius:12px;
border:1px solid rgba(167,243,208,.3);
transition:.2s;
}
a:hover{background:rgba(167,243,208,.1)}
.footer{margin-top:32px;color:#64748b;font-size:13px}
</style>
</head>
<body>
<div class="card">
<div class="emoji">🚕</div>
<h1>RideShare API</h1>
<span class="tag">Live · v1.0.0</span>
<p>FastAPI backend powering the RideShare Android demo: rider auth, vehicle selection, driver matching, two-leg ride flow, and Stripe payment.</p>
<p>This service is consumed by the mobile app — there is no web UI here on purpose.</p>
<div class="links">
<a href="/health">/health</a>
<a href="/docs">/docs · OpenAPI</a>
</div>
<div class="footer">Built by Sheharzad Salahuddin · Hosted on Hugging Face Spaces</div>
</div>
</body>
</html>"""
@app.get('/', response_class=HTMLResponse, include_in_schema=False)
async def landing():
return _LANDING_HTML