Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Network Core

一个能够用简洁的方式来构建通信服务的轻量级框架。

方法

此项目已上传 acdpnet · PyPI ,快速安装可使用以下命令。

pip install acdpnet -i https://pypi.org/simple

构建服务

基本框架

from acdpnet import services

app = services.Tree()

# extension

app.run(('0.0.0.0', 1035), token='ASDF')

通过以上代码可以快速构建一个服务端,但仍然无法投入使用,在此之上还需要加上用户认证的功能。

用户认证

简单的用户创建方式
app.idf.acessuid = {
    'Name':'Password'
}
自定义用户认证
class Login(services.Idenfaction):
    def setup(self):
        pass
    
    def Idenfy(self, account:str, key:str):
        if key == self.acessuid.get(account):
            return True
        else:
            return False

app.idf = Login()

在继承 services.Idenfaction 后,认证的方式请写在 Idenfy 方法中。之后覆盖 app.idf 。

服务拓展

完成了基本的框架后,就可以为服务端添加功能啦。

通过函数拓展
from acdpnet.tools import Conet
# 引用此类是为了在写代码时出现代码提示,可不引用

@app.command('command_name')
def Dosomething(conet:Conet):
    pass
通过类拓展
from acdpnet.tools import Conet

class Serv:
    def command_name_1(conet:Conet):
    	pass
    
    def command_name_2(conet:Conet):
    	pass

app.extension(Serv)

在通过此方法拓展时,请勿在方法中添加 self ,同时方法的名称便是指令的名称。

通过内置拓展添加

此库中内置了一些预先写好的拓展,可以通过以下方式添加。

from acdpnet.extension import transfer

app.extension(transfer.Transfer)

构建客户端

基本方式

from acdpnet import nodes

app = nodes.BasicNode('Name', 'Password')
app.connect(('localhost', 1035), token='ASDF')

# do something

app.close()

发送与接收

发送命令及数据
data = {
    ...
}
app.send('Your command', data)
接收命令与数据
resp = app.recv()
# 由服务端决定返回 dict 或 list

Metadata

Release files for acdpnet 2.2.1

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

Source distribution (sdist)

Source distribution for acdpnet 2.2.1
File Size Uploaded Provenance
acdpnet-2.2.1.tar.gz 15.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for acdpnet 2.2.1
File Interpreter ABI Platform
acdpnet-2.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / acdpnet-2.2.1.tar.gz

Download URL acdpnet-2.2.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
bc6085c92705872667f5818442ff446505a4037d03ba504c41fadc92423edb0a
BLAKE2b-256 checksum
How to use checksums
df2f2bc8b9d7bcb18c9cbbf0cd6dc341dcff545120e72b100a4ca120cf91cd0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Release files / acdpnet-2.2.1-py3-none-any.whl

Download URL acdpnet-2.2.1-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
080d52a9dabc404460596208c72b6fb78521a725fc7280c75a768fabfa746c5b
BLAKE2b-256 checksum
How to use checksums
69b5769b11efedfc68541ad3122dfd5bbd8b7bf41f22133d98eab029e74c24f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.12

Security for acdpnet 2.2.1

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.

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