-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb.py
More file actions
49 lines (40 loc) · 1.71 KB
/
Copy pathweb.py
File metadata and controls
49 lines (40 loc) · 1.71 KB
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
41
42
43
44
45
46
47
48
49
"""Hypercorn launch script for CodeBuddy2API.
The application object lives in src/main.py — this file just imports it,
prints a startup banner, and runs the server. Existing deploy commands
(``python web.py``, ``hypercorn web:app``, ``uv run hypercorn web:app``)
continue to work unchanged.
"""
import asyncio
from src.core.config import get_server_host, get_server_port
from src.core.logging import logger
from src.main import app
__all__ = ["app"]
if __name__ == "__main__":
from hypercorn.asyncio import serve
from hypercorn.config import Config
port = get_server_port()
host = get_server_host()
logger.info("=" * 60)
logger.info("Starting CodeBuddy2API")
logger.info("=" * 60)
logger.info(f"Main Service: http://{host}:{port}")
logger.info("=" * 60)
logger.info("API Endpoints (OpenAI):")
logger.info(f" Base URL: http://{host}:{port}/codebuddy/v1")
logger.info(f" Chat: POST http://{host}:{port}/codebuddy/v1/chat/completions")
logger.info(f" Models: GET http://{host}:{port}/codebuddy/v1/models")
logger.info("=" * 60)
logger.info("API Endpoints (Anthropic):")
logger.info(f" Base URL: http://{host}:{port}/codebuddy")
logger.info(f" Messages: POST http://{host}:{port}/codebuddy/v1/messages")
logger.info("=" * 60)
logger.info("Credentials & Auth:")
logger.info(f" Credentials: GET http://{host}:{port}/codebuddy/v1/credentials")
logger.info(f" Auth Start: GET http://{host}:{port}/codebuddy/auth/start")
logger.info("=" * 60)
config = Config()
config.bind = [f"{host}:{port}"]
config.accesslog = None
config.errorlog = "-"
config.loglevel = "INFO"
asyncio.run(serve(app, config)) # type: ignore[arg-type]