Skip to main content
Glama
Vivek-k3

Models PLUS

by Vivek-k3
server.ts1.77 kB
import Index from "../index.html"; import { Rendered } from "./render"; import path from "path"; Bun.serve({ port: 16_000, routes: { "/": Index, "/assets/*": (req) => { const file = Bun.file( path.join(import.meta.dir, new URL(req.url).pathname), ); return new Response(file); }, "/logos/*": async (req) => { const url = new URL(req.url); const provider = url.pathname.split('/')[2].replace('.svg', ''); const logoPath = path.join(import.meta.dir, "..", "..", "..", "providers", provider, "logo.svg"); const defaultLogoPath = path.join(import.meta.dir, "..", "..", "..", "providers", "logo.svg"); let file = Bun.file(logoPath); if (!await file.exists()) { file = Bun.file(defaultLogoPath); } return new Response(file, { headers: { "Content-Type": "image/svg+xml", "Cache-Control": "public, max-age=3600" } }); }, }, }); const server = Bun.serve({ development: true, hostname: "0.0.0.0", async fetch(req) { // Reject WebSocket upgrade requests if (req.headers.get("upgrade") === "websocket") { return new Response("WebSocket upgrades not supported", { status: 426, headers: { Upgrade: "Required", }, }); } const url = new URL(req.url); url.host = "localhost:16000"; const result = fetch(url.toString(), req); if (url.pathname !== "/") return result; let html = await result.then((r) => r.text()); html = html.replace("<!--static-->", Rendered); return new Response(html, { headers: { "Content-Type": "text/html", }, }); }, }); console.log(`Server running at ${server.hostname}:${server.port}`);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Vivek-k3/modelsplus'

If you have feedback or need assistance with the MCP directory API, please join our Discord server