Skip to main content

A simple framework for building SDCP servers

Project description

SDCP

A simple Python framework for building SDCP (Secure Data Communication Protocol) servers, inspired by Flask.

Installation

pip install sdcp

Requirements

You need a running SDCP main authentication server that will be used by both the client and the server. The default server is mineflare.app:300. Please email contact@mineflare.app to create a server key.

Quick Start

from sdcp import SDCP, Request, Response, html

app = SDCP(
    server_id="YOUR-SERVER-ID",
    server_key="YOUR-SERVER-KEY",
    main_server_host="mineflare.app",
    main_server_port=300,
)

@app.route("/")
def index(request: Request) -> Response:
    return html("<head><title>Home</title></head><body><h1>Hello!</h1></body>")

@app.route("/about")
def about(request: Request) -> Response:
    return html("<head><title>About</title></head><body><h1>About</h1></body>")

@app.not_found
def not_found(request: Request) -> Response:
    return html(f"<h1>404 - {request.path} not found</h1>")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=299, debug=True)

API Reference

SDCP(server_id, server_key, main_server_host, main_server_port)

Creates an SDCP app instance.

Parameter Default Description
server_id "" This server's ID
server_key "" This server's encryption key
main_server_host "127.0.0.1" Hostname of the main auth server
main_server_port 300 Port of the main auth server

@app.route(path)

Registers a handler for a given path. Use * at the end for wildcard matching.

@app.route("/blog/*")
def blog(request: Request) -> Response:
    return html(f"<h1>Blog post: {request.path}</h1>")

@app.not_found

Registers a custom 404 handler.

Request

Attribute Description
request.path The path requested by the client
request.client_id The authenticated client's ID

html(content)

Helper to return an HTML response.

app.run(host, port, debug)

Starts the server.

Parameter Default Description
host "0.0.0.0" Interface to bind to
port 299 Port to listen on
debug False Print connection logs

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

sdcp-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

sdcp-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file sdcp-0.1.1.tar.gz.

File metadata

  • Download URL: sdcp-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for sdcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c3ae013ddee20fcf32d0348e104414230360dae4237b3e9faf45741345162416
MD5 e5f2cd5303dea031a72d7cf2838ea59e
BLAKE2b-256 e5d533d7223d1aef2a141a2885a530962ad283de7504fb993af84a1779ab7667

See more details on using hashes here.

File details

Details for the file sdcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sdcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for sdcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b0cf86b6bc5acad37c7f9b699af0693d6c3612b315744e9d7b7824afe03550b
MD5 6802140ee158c7ac09da761bbd5b9f03
BLAKE2b-256 1e138e95d6948cd76299222e9f5b088129bebbcebdf2551bccb828fef0b0ca1a

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