Discuss Scratch

ninjaMAR
Scratcher
1000+ posts

mproto : python library for making custom web protocols

In construction
About
Make custom web protocols such as
test://INSERTDATAHERE
Requires
  • python >=3.7 (I haven't tested on 3.6)
  • pip (optional)
Installation
pip
pip3 install mproto
Information
I have included some protocols to test the program
Examples
Make a protocol
from mproto import BaseProtoHandler
import urllib.request as urlreq
class MyProto(BaseProtoHandler):
    def myproto_open(self,req): #the function name should be protocol+_open
        #handles the request
        return req.get_full_url()
myproto.install()
print(urlreq.urlopen('myproto://abc')) #should output myproto://abc
Use a default protocol
from mproto.defaults import TestProto
import urllib.request as urlreq
TestProto.install()
print(urlreq.urlopen('test://abc'))
Urls
Notes
  • You can use mproto.install(*proto) to install instead of proto.install()

Last edited by ninjaMAR (May 19, 2021 21:11:53)

ninjaMAR
Scratcher
1000+ posts

mproto : python library for making custom web protocols

bump
PkmnQ
Scratcher
1000+ posts

mproto : python library for making custom web protocols

Seems interesting. Where can I see how to make it respond to requests?

Last edited by PkmnQ (May 20, 2021 17:09:27)

ninjaMAR
Scratcher
1000+ posts

mproto : python library for making custom web protocols

PkmnQ wrote:

Seems interesting. Where can I see how to make it respond to requests?
Requests is build on urllib3 which is build on http.client. Since I use urllib for my code, I would need to switch to http.client somehow
gdpr5b78aa4361827f5c2a08d700
Scratcher
1000+ posts

mproto : python library for making custom web protocols

neat
ninjaMAR
Scratcher
1000+ posts

mproto : python library for making custom web protocols

why do the stats seem false? how many people downloaded it?
Raihan142857
Scratcher
1000+ posts

mproto : python library for making custom web protocols

ninjaMAR wrote:

why do the stats seem false? how many people downloaded it?
you
gdpr5b78aa4361827f5c2a08d700
Scratcher
1000+ posts

mproto : python library for making custom web protocols

ninjaMAR wrote:

why do the stats seem false? how many people downloaded it?
if people are using it in replit, then it'll download every time the repl starts.
ninjaMAR
Scratcher
1000+ posts

mproto : python library for making custom web protocols

Raihan142857 wrote:

ninjaMAR wrote:

why do the stats seem false? how many people downloaded it?
you
it says 13 daily downloads
PkmnQ
Scratcher
1000+ posts

mproto : python library for making custom web protocols

ninjaMAR wrote:

PkmnQ wrote:

Seems interesting. Where can I see how to make it respond to requests?
Requests is build on urllib3 which is build on http.client. Since I use urllib for my code, I would need to switch to http.client somehow
Ok, then what can I use this for?
ninjaMAR
Scratcher
1000+ posts

mproto : python library for making custom web protocols

PkmnQ wrote:

ninjaMAR wrote:

PkmnQ wrote:

Seems interesting. Where can I see how to make it respond to requests?
Requests is build on urllib3 which is build on http.client. Since I use urllib for my code, I would need to switch to http.client somehow
Ok, then what can I use this for?
Use it to make custom url protocols. I could try to switch to http.client somehow

Powered by DjangoBB