Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

mr-josh/spiders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spiders

V: 0.1.1
An asynchronous server made in pure python

Installation

Requirements

  • Python >= 3.9
  • A spare brain cell 🧠

Install

pip install Spiders

https://pypi.org/project/Spiders/

Usage

Example Web Server

from spider import Server, serve
from spider.web import WebService, HTTPResponse

@serve
class MyWebServer(Server):
    service = WebService
    routes = {
        r"^/?$": HTTPResponse("Hello World!")
    }

Example API Endpoint

from spider import Server, serve
from spider.web import WebService, responses

def my_api(request):
    return responses.JSONResponse({
        "path": request.path,
        "params": str(request.params),
        "body": request.body_json
    })

@serve
class MyAPIEndpoint(Server):
    service = WebService
    routes = {
        r"^/foo/bar/?$": my_api
    }