feat: add /reset-password page
Browse filesFiles changed (3)
- README.md+95-95
- app.py+3-3
- bootstrap.py+17-5
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394951234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495---
title: Habadashi Login Gateway
emoji: ๐
colorFrom: blue
colorTo: green
sdk: docker
pinned: false
---
# Habadashi Login Gateway
Public gateway with Supabase authentication that dynamically loads the private ver20 application from `DLPO/habadashi` Space.
## Features
- Supabase email/password authentication
- Cookie-based session management
- Dynamic loading of private application code (source code not exposed in public repo)
- Role-based access control via profiles table
## Environment Variables (Set in HF Space Secrets)
- `SUPABASE_URL`: Your Supabase project URL
- `SUPABASE_KEY`: Your Supabase anon/service key
- `HF_TOKEN`: Hugging Face token with access to private `DLPO/habadashi` Space
- `OPENAI_KEY`: OpenAI API key (required by ver20)
- `CLIENTPOOL`: Client pool configuration (required by ver20)
## Architecture
1. User visits public Space
2. Bootstrap downloads ver20 from private `DLPO/habadashi` Space
3. User logs in with Supabase credentials
4. On successful login, ver20 Gradio app is mounted at `/app/`
5. User profile and organization info loaded from `profiles` table
## Startup Phase Logging
The application logs structured startup phases to help diagnose issues. Look for these phase markers in the logs:
### Expected Startup Sequence
1. `[STARTUP_META]` - Environment and configuration info
2. `[PHASE] bootstrap_start` - Begin downloading private app
3. `[PHASE] bootstrap_end success=true` - Private app downloaded
4. `[PHASE] supabase_init_start` - Initialize Supabase client
5. `[PHASE] supabase_init_end success=true` - Supabase ready
6. `[PHASE] fastapi_init_start/end` - FastAPI app created
7. `[PHASE] create_ui_start/end` - Login UI created
8. `[PHASE] import_ver20_start` - Import ver20 app
9. `[PHASE] import_ver20_end success=true` - Ver20 loaded
10. `[PHASE] mount_login_start/end` - Login UI mounted
11. `[PHASE] mount_app_start/end` - Ver20 app mounted
12. `[STARTUP_COMPLETE]` - All phases complete
### Health Check Endpoint
Once started, check the health endpoint:
```bash
curl https://your-space.hf.space/healthz
```
Expected response:
```json
{
"ok": true,
"ver20_loaded": true,
"private_app_dir": "./private_app"
}
```
### Debugging Startup Failures
If the Space fails to start or restarts repeatedly:
1. **Check the last phase reached** in logs
2. **Look for `[ERROR]` and `[TRACEBACK]` markers** after the last phase
3. **Common failure points:**
- `bootstrap_end success=false` - HF_TOKEN missing or invalid
- `supabase_init_end success=false` - SUPABASE_URL/KEY missing
- `import_ver20_end success=false` - Ver20 app.py structure issue
- No phases after `mount_app_end` - Port binding or health check issue
### Request Logging
All HTTP requests are logged with:
- `[REQUEST]` - Incoming request (method, path)
- `[RESPONSE]` - Response status and duration
Example:
```
[REQUEST] method=GET path=/
[RESPONSE] method=GET path=/ status=307 duration=0.015s
```---title: mbok_devemoji: ๐colorFrom: bluecolorTo: greensdk: dockerpinned: false---
# mbok_dev
Public gateway with Supabase authentication that dynamically loads the private ver20 application from `DLPO/habadashi` Space.
## Features
- Supabase email/password authentication- Cookie-based session management- Dynamic loading of private application code (source code not exposed in public repo)- Role-based access control via profiles table
## Environment Variables (Set in HF Space Secrets)
- `SUPABASE_URL`: Your Supabase project URL- `SUPABASE_KEY`: Your Supabase anon/service key- `HF_TOKEN`: Hugging Face token with access to private `DLPO/habadashi` Space- `OPENAI_KEY`: OpenAI API key (required by ver20)- `CLIENTPOOL`: Client pool configuration (required by ver20)
## Architecture
1. User visits public Space2. Bootstrap downloads ver20 from private `DLPO/habadashi` Space3. User logs in with Supabase credentials4. On successful login, ver20 Gradio app is mounted at `/app/`5. User profile and organization info loaded from `profiles` table
## Startup Phase Logging
The application logs structured startup phases to help diagnose issues. Look for these phase markers in the logs:
### Expected Startup Sequence
1. `[STARTUP_META]` - Environment and configuration info2. `[PHASE] bootstrap_start` - Begin downloading private app3. `[PHASE] bootstrap_end success=true` - Private app downloaded4. `[PHASE] supabase_init_start` - Initialize Supabase client5. `[PHASE] supabase_init_end success=true` - Supabase ready6. `[PHASE] fastapi_init_start/end` - FastAPI app created7. `[PHASE] create_ui_start/end` - Login UI created8. `[PHASE] import_ver20_start` - Import ver20 app9. `[PHASE] import_ver20_end success=true` - Ver20 loaded10. `[PHASE] mount_login_start/end` - Login UI mounted11. `[PHASE] mount_app_start/end` - Ver20 app mounted12. `[STARTUP_COMPLETE]` - All phases complete
### Health Check Endpoint
Once started, check the health endpoint:
```bashcurl https://DLPO-mbok-dev.hf.space/healthz```
Expected response:```json{ "ok": true, "ver20_loaded": true, "private_app_dir": "./private_app"}```
### Debugging Startup Failures
If the Space fails to start or restarts repeatedly:
1. **Check the last phase reached** in logs2. **Look for `[ERROR]` and `[TRACEBACK]` markers** after the last phase3. **Common failure points:** - `bootstrap_end success=false` - HF_TOKEN missing or invalid - `supabase_init_end success=false` - SUPABASE_URL/KEY missing - `import_ver20_end success=false` - Ver20 app.py structure issue - No phases after `mount_app_end` - Port binding or health check issue
### Request Logging
All HTTP requests are logged with:- `[REQUEST]` - Incoming request (method, path)- `[RESPONSE]` - Response status and duration
Example:```[REQUEST] method=GET path=/[RESPONSE] method=GET path=/ status=307 duration=0.015s```123345619 unmodified lines2627282929303132521 unmodified lines554555556557557558559560#!/usr/bin/env python3"""Habadashi Login Gateway - Main entry pointmbok_dev - Main entry pointPublic Space that loads private ver20 app dynamically"""
19 unmodified lines
# --- Startup Meta Info ---print("=" * 80)print("๐ Starting Habadashi Login Gateway")print("๐ Starting mbok_dev")print("=" * 80)print(f"[STARTUP_META] Python version: {sys.version}")print(f"[STARTUP_META] CWD: {os.getcwd()}")521 unmodified lines print("[PHASE] mount_app_end path=/app protected=true ver20=false fallback=true")
print("=" * 80)print("๐ Habadashi Login Gateway Ready!")print("๐ mbok_dev Ready!")print("=" * 80)print(f"[STARTUP_COMPLETE] All phases completed successfully")print(f"[STARTUP_COMPLETE] Access URLs:")12334567891011121314151617181920218 unmodified lines30313224253334353637383928404142433244454647#!/usr/bin/env python3"""Bootstrap module - Downloads ver20 from private DLPO/habadashi SpaceBootstrap module - Downloads ver20 from private Space. mbok_dev / mbok-dev โ DLPO/habadashi_dev mbok (ใใฎไป) โ DLPO/habadashi"""
import osfrom pathlib import Pathfrom huggingface_hub import snapshot_download
def _resolve_repo_id() -> str: """SPACE_ID ็ฐๅขๅคๆฐใใๅ็
งๅ
private Space ใฎ repo_id ใๆฑบๅฎใใใ""" space_id = os.environ.get("SPACE_ID", "").lower() if "mbok_dev" in space_id or "mbok-dev" in space_id: return "DLPO/habadashi_dev" return "DLPO/habadashi"
def get_hf_token(): """Get HF_TOKEN from environment variable""" token = os.environ.get("HF_TOKEN")8 unmodified lines
def download_private_app(force_download: bool = False): """ Download ver20 application from private DLPO/habadashi Space Download ver20 application from private Space. ๅ็
งๅ
ใฏ SPACE_ID ็ฐๅขๅคๆฐใงๆฑบๅฎ: mbok_dev / mbok-dev โ DLPO/habadashi_dev mbok (ใใฎไป) โ DLPO/habadashi
Args: force_download: If True, re-download even if already cached
Returns: Path: Local directory containing downloaded ver20 files """ repo_id = "DLPO/habadashi" repo_id = _resolve_repo_id() repo_type = "space" local_dir = Path("./private_app") README.md+95-95
app.py+3-3
bootstrap.py+17-5