MCPcopy
hub / github.com/Sophomoresty/gemini-web2api / do_GET

Method do_GET

gemini_web2api/server.py:84–106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

82 self.end_headers()
83
84 def do_GET(self):
85 try:
86 if self.path.startswith("/v1/") and not self._authorized():
87 self.send_json({"error": {"message": "invalid api key"}}, 401)
88 return
89 if self.path == "/v1/models":
90 self.send_json({"object": "list", "data": [
91 {"id": n, "object": "model", "created": 1700000000,
92 "owned_by": "google", "description": c["desc"]}
93 for n, c in MODELS.items()
94 ]})
95 elif self.path.startswith("/v1beta/models"):
96 self.send_json({"models": [
97 {"name": f"models/{n}", "displayName": n, "description": c["desc"],
98 "supportedGenerationMethods": ["generateContent", "streamGenerateContent"]}
99 for n, c in MODELS.items()
100 ]})
101 elif self.path == "/":
102 self.send_json({"status": "ok", "version": __version__, "models": list(MODELS.keys())})
103 else:
104 self.send_json({"error": "not found"}, 404)
105 except (BrokenPipeError, ConnectionResetError):
106 pass
107
108 def do_POST(self):
109 try:

Callers

nothing calls this directly

Calls 2

_authorizedMethod · 0.95
send_jsonMethod · 0.95

Tested by

no test coverage detected