Skip to main content

FastAPI-style Gemini Protocol Framework

Project description

FastGemini

A FastAPI-style framework for building Gemini protocol servers in Python.

Features

  • 🚀 FastAPI-style decorators - Define routes with familiar @app.route() syntax
  • 📦 Router support - Organize routes with GeminiRouter (like APIRouter)
  • 🔧 Path parameters - Extract values from URLs: /user/{username}
  • Async/await - Built on asyncio for high-performance async I/O
  • 🛡️ TLS/SSL - Native client certificate support
  • 🎯 Type hints - Full Pydantic integration for request/response models

Installation

pip install fastgemini

Quick Start

from fastgemini import GeminiApp, success
from fastgemini.schema import GeminiRequest, GeminiResponse

app = GeminiApp(
    certfile="path/to/cert.cer",
    keyfile="path/to/key.key",
)

@app.route("/")
async def index(request: GeminiRequest) -> GeminiResponse:
    return success("# Welcome to Gemini!\n")

@app.route("/hello/{name}")
async def hello(request: GeminiRequest) -> GeminiResponse:
    name = request.path_params["name"]
    return success(f"# Hello, {name}!\n")

if __name__ == "__main__":
    app.run()

Using Routers

from fastgemini import GeminiApp, GeminiRouter, success

app = GeminiApp(
    certfile="path/to/cert.cer",
    keyfile="path/to/key.key",
)
users = GeminiRouter(prefix="/users")

@users.route("/")
async def list_users(request):
    return success("# Users\n=> /users/alice Alice\n")

@users.route("/{username}")
async def get_user(request):
    return success(f"# User: {request.path_params['username']}\n")

app.include_router(users)

Response Helpers

from fastgemini import success, redirect, not_found, input_required, error

# Success with body
success("# Hello World\n")

# Redirects
redirect("/new-location")
redirect("/permanent", permanent=True)

# Errors
not_found("Page not found")
error("Something went wrong")

# Input prompts
input_required("Enter your name:")
input_required("Enter password:", sensitive=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastgemini-0.1.4.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastgemini-0.1.4-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file fastgemini-0.1.4.tar.gz.

File metadata

  • Download URL: fastgemini-0.1.4.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastgemini-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9afabe4936433ceb33416183a3046d831b093661203813ec0b75ae4ffaff6db5
MD5 f2f870a343ce8fda784490cef2faf2f1
BLAKE2b-256 52c60df08d05425cbd690a775f80e1a728ed8b823800aaee9f459de7ef0eec67

See more details on using hashes here.

File details

Details for the file fastgemini-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: fastgemini-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.22 {"installer":{"name":"uv","version":"0.9.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for fastgemini-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f83af1f98ae808ee273d35522c48cd8ca716c385fc1a9268ed8b21bfefb588eb
MD5 65744fa43cd19d76875cf43d96c3cd9e
BLAKE2b-256 dae7e59c5f0978025456ae9c102a8f261986c1179af43498a7aac65cb8f97b81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page