Very simple way to interact with any http and Websocket requests
from darius.server import server,routes
from darius.client_side import status
class Home(routes.View):
def GET(self,request,**kwargs):
return status.Http200().__call__("<h1>Home Page</h1>")
def POST(self,request,**kwargs):
return status.HttpBinary().__call__("dog.png",display_in_browser=True)
def __init__(self,*args,**kwargs):
"""Optional : Add your own custom HTTP method requests"""
super(Home,self).__init__(*args,**kwargs)
self.cases['CREATE'] = self.POST # Custom HTTP method
class Chat(routes.SocketView):
def onConnect(self,client,**kwargs):
key = kwargs.get("key")
username = kwargs.get("headers")['Cookies']['username']
self.accept(client,key)
return {"username" : username,"id" : ord(username[0]) % 51} # Stored as state with client
def onMessage(self,client,**kwargs):
data = kwargs.get('data') # Message sent
path_info = kwargs.get("path_info") # Containing information about clients
send = kwargs.get('send_function') # Functions to send data
# Send the message to every client
for client in path_info['clients']:
if(client['username'].startswith("a")) or client['id'] % 2 == 0:
send(client,data)
def onExit(self,client,**kwargs):
print("Client exited!")
And then to actually list the paths and start the Server
WS_URLS = {
r'/chat(\/)?' : Chat()
}
HTTP_URLS = {
r'/home(\/)?' : Home()
}
server.Server(WS_URLS,HTTP_URLS,port=8000).start()
More can be found at Github
Metadata
Release files for darius 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| darius-1.0.0.tar.gz | 20.2 kB | Without provenance | Details for darius-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| darius-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for darius-1.0.0-py3-none-any.whl |
Total release size: 42.8 kB
Release files / darius-1.0.0.tar.gz
| Download URL | darius-1.0.0.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
350929fc394dd06cecd8deba317ac763511110be0b6d4bc6964a939a7c37954e
|
|
BLAKE2b-256 checksum How to use checksums |
57dc4e824553330295ffd462540706eb776877f036ced64b7e55eab30a24f1c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6
|
Release files / darius-1.0.0-py3-none-any.whl
| Download URL | darius-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b8044a66391ca75b93e2bd69dec9d1d41abda8ea34ab849a860dd77857303f7e
|
|
BLAKE2b-256 checksum How to use checksums |
a3b1d25f3819f038f7f929b0402920f45fab5b430285d3777b1a21bc83a04cb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.6
|
Security for darius 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.