Skip to main content

Perseus: RESTful API Server Framework

Perseus is a Python framework for quickly building RESTful API servers with minimal effort.

Perseus provides an initial set of core services that supports the following features:

  • Client application registration with API keys generation
  • Client application access control with RESTful request signature
  • Client application and RESTful API server version compatibility check
  • User authentication and session management
  • Team/group management
  • RESTful request logging with data sensitiveness support
  • RESTful service automatic discovery
  • HTTP request query parameters & body JSON message automatically parsing (depending on the HTTP method used) with data type check and conversion

Perseus is based on Tornado for handling client network connection.

RESTful API Request Handler

from majormode.perseus.service.base_http_handler import HttpRequest
from majormode.perseus.service.base_http_handler import HttpRequestHandler
from majormode.perseus.service.base_http_handler import http_request

import AttendantService


class AttendantServiceHttpRequestHandler(HttpRequestHandler):
    @http_request(r'^/attendant/session$',
                  http_method=HttpRequest.HttpMethod.POST,
                  authentication_required=False,
                  sensitive_data=True,
                  signature_required=False)
    def sign_in(self, request):
        email_address = request.get_argument(
            'email_address',
            data_type=HttpRequest.ArgumentDataType.email_address,
            is_required=True)

        password = request.get_argument(
            'password',
            data_type=HttpRequest.ArgumentDataType.string,
            is_required=True)

        return AttendantService().sign_in(request.app_id, email_address, password)

Configure the environment variables

# Copyright (C) 2021 Majormode.  All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Connection properties of the RESTful API server instances.  Defaults
# to 127.0.0.1:8081.
API_SERVER_HOSTNAME=127.0.0.1
API_SERVER_PORTS=

# Root path of the Network File System (NFS) -- referring to the
# distributed file system (not the protocol) -- where the Content
# Delivery Network (CDN) files are stored into, such as avatars, etc.
CDN_NFS_ROOT_PATH=

# Hostname of the Content Delivery Network (CDN) server that hosts media
# files such as avatars, etc.
CDN_URL_HOSTNAME=

# Environment stage of the API server instances.  Possible values are:
#
# - dev
# - int
# - staging
# - prod
#
# Defaults to `dev`.
ENVIRONMENT_STAGE=

# Connection properties to a Memcached server (a distributed memory
# object caching system).  Defaults to 127.0.0.1:11211.
MEMCACHED_HOSTNAME = '127.0.0.1'
MEMCACHED_PORT = 11211

# Threshold for the logger to level.  Logging messages which are less
# severe than the specified level will be ignored; logging messages
# which have this severity level or higher will be emitted.  Possible
# values are:
#
# - debug
# - info
# - warning
# - error
# - critical
#
# Default to 'debug'.
LOGGING_LEVEL=

# Environment variables to select default parameter values to connect
# to PostgreSQL Relational Database Management System.
PG_HOSTNAME=localhost
PG_PORT=5432
PG_DATABASE_NAME=
PG_USERNAME=
PG_PASSWORD=

Run the RESTful API Server Processes

$ fab start --port=65180,65181,...

Hashtags/Topics: #perseus #restful #api #server #framework #python

Metadata

Release files for perseus-restful-api-framework 1.28.15

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for perseus-restful-api-framework 1.28.15
File Size Uploaded
perseus_restful_api_framework-1.28.15.tar.gz 5.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for perseus-restful-api-framework 1.28.15
File Interpreter ABI Platform
perseus_restful_api_framework-1.28.15-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 MB

Release files / perseus_restful_api_framework-1.28.15.tar.gz

Download URL perseus_restful_api_framework-1.28.15.tar.gz
Size 5.7 MB
Tags Source
SHA-256 checksum
How to use checksums
a59f54f1b3612cae7067966f5e9399cc1574453ac0fbbb9b2cd73cd3596cf7e3
BLAKE2b-256 checksum
How to use checksums
e841cb042478f4935e046f69a34b1bf9fc16e2b77fb0949ca8db80ad02b43183
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.7 Darwin/24.2.0

Release files / perseus_restful_api_framework-1.28.15-py3-none-any.whl

Download URL perseus_restful_api_framework-1.28.15-py3-none-any.whl
Size 5.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
edc65edb81bacf78719c3cf27f3e643daaffa254b94478d51706f1181247f768
BLAKE2b-256 checksum
How to use checksums
e5ec3c4ba448005dbe6586af132f91663cda008aefbee91fbfb574d1c901cbbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.12.7 Darwin/24.2.0

Release history Release notifications | RSS feed

This release

1.28.15 This release

2 release files

1.28.9

2 release files

1.28.8

2 release files

1.28.7

2 release files

1.28.6

2 release files

1.28.5

2 release files

1.28.2

2 release files

1.28.1

2 release files

1.28.0

2 release files

1.27.9

2 release files

1.27.8

2 release files

1.27.7

2 release files

1.27.6

2 release files

1.27.2

2 release files

1.27.1

2 release files

1.27.0

2 release files

1.26.9

2 release files

1.26.7

2 release files

1.26.6

2 release files

1.26.5

2 release files

1.26.4

2 release files

1.26.3

2 release files

1.25.8

2 release files

1.25.7

2 release files

1.25.6

2 release files

1.25.5

2 release files

1.25.4

2 release files

1.25.3

2 release files

1.25.2

2 release files

1.25.1

2 release files

1.25.0

2 release files

1.24.8

2 release files

1.24.7

2 release files

1.24.6

2 release files

1.24.5

2 release files

1.24.4

2 release files

1.24.3

2 release files

1.24.2

2 release files

1.24.1

2 release files

1.24.0

2 release files

1.23.2

2 release files

1.21.0

2 release files

1.20.5

2 release files

1.20.4

2 release files

1.20.3

2 release files

1.20.2

2 release files

1.20.1

2 release files

1.20.0

2 release files

1.14.6

2 release files

1.13.3

2 release files

1.12.9

2 release files

1.11.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page