Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
MaxiHuHe04 edited this page Nov 1, 2019 · 3 revisions

Cryptic-Game Python3-Lib

🔥 This guide does not explain how this library works internally. It is just a quick guide on which features it provides. 🔥

Installation

pip3 install cryptic-game

Enviroment Variables

Variable Functionality
MODE Available: debug and production
SERVER_HOST Hostname of the main server
SERVER_PORT Microservice communication port of the main server
DATA_LOCATION SQLite database file location
DBMS Database management system; Available: mysql and sqlite
SQLITE_FILE Name of the SQLite database file (only used if DBMS is sqlite)
MYSQL_HOSTNAME Hostname of the MySQL server
MYSQL_PORT Port of the MySQL server
MYSQL_DATABASE Name of the MySQL database to use
MYSQL_USERNAME MySQL username to use
MYSQL_PASSWORD The password of the MySQL user
PATH_LOGFILE Path where your log-files will be stored to
DSN "Data Source Name" of your Sentry instance
RELEASE The release that will be reported to Sentry

Requirements

See the requirements.txt

Init your Microservice

from cryptic import Microservice

m = Microservice("your_ms_name")

# Database wrapper, relevant for later
wrapper = m.get_wrapper()

Defining endpoints

from scheme import Text

m.user_endpoint(path = ["info"], requires = {"user_name": Text()}
def info(data: dict, user: str):
     return {"message": "Hi " + data["user_name"] + ", your uuid is " + user}

You can specify under which path this endpoint is reachable and which input scheme it needs. The library will automatically validate the input and return {"error": "invalid_input_data"} if it isn't valid.