Spaces:
Running
Running
| import asyncio | |
| import threading | |
| from uvicorn import Server, Config | |
| from httpx import Client | |
| import time | |
| from free_claude_code.runtime.bootstrap import build_asgi_app | |
| from free_claude_code.config.admin.values import get_admin_settings | |
| def run_server(): | |
| settings = get_admin_settings() | |
| app = build_asgi_app(settings) | |
| config = Config(app, host="127.0.0.1", port=7862, log_level="error") | |
| server = Server(config) | |
| server.run() | |
| t = threading.Thread(target=run_server, daemon=True) | |
| t.start() | |
| time.sleep(3) | |
| try: | |
| with Client() as client: | |
| res = client.post("http://127.0.0.1:7862/v1/messages", json={ | |
| "model": "nvidia/nemotron", | |
| "messages": [{"role": "user", "content": "hi"}], | |
| "max_tokens": 10 | |
| }, headers={"Authorization": "Bearer TEST"}) | |
| print(res.status_code) | |
| print(res.text) | |
| except Exception as e: | |
| print(f"Request failed: {e}") | |