Package: httpsweet
httpsweetAn HTTP server to easily download and upload files.It was created with flexibility in mind, allowing be used in many different situations, therefore in allows deploy the very same operation in many different ways. For more information see theSpecification section.Note: This software is not intended for production enviroment, but for test purposes, therefore be careful with its use, since it don't provide any security mechanism.InstallationFrom python packages:pip3installhttpsweetFrom repository:gitclonehttps://gitlab.com/Zer1t0/httpsweetcdhttpsweet/
python3setup.pyinstall# required only in case of system installationExamplesThis section show some examples of the common operations.Download fileDownload a filetest:curl127.0.0.1:8000/test
curl127.0.0.1:8000/?path=testcurl127.0.0.1:8000/-d'action=download&path=test'Download part of a filetest:curl'127.0.0.1:8000/test?offset=10&size=20'curl'127.0.0.1:8000/?offset=10&size=20&path=test'curl127.0.0.1:8000/-d'action=download&offset=10&size=20&path=test'Upload fileUpload a file namedtest_up:curl127.0.0.1:8000/test_up-H"Content-Type: application/octet-stream"--data'thedata'curllocalhost:8000/test_up-H"Content-Type: application/octet-stream"--data-binary"@/etc/hosts"curl'127.0.0.1:8000/test_up?action=upload_file&data=thedata'Upload a file appending:curl127.0.0.1:8000/test_app?append=t-H"Content-type: application/octet-stream"--data"thedata"curl'127.0.0.1:8000/test_app?action=upload_file&data=thedata&append=t'Upload base64 encoded:curl127.0.0.1:8000/test_64?encoding=64-H'Content-type: application/octet-stream'--data'dGhlZGF0YQo='curl'127.0.0.1:8000/?action=upload_file&path=test_64&data=dGhlZGF0YQo&encoding=64'HTTPSThe server also support the HTTPS protocol, for which you should provide a certificate with a private key, by using the parameters--certand--key. In case of genereting a cert which also includes the private key, only the--certparameter must be used.To generate an auto-self certificate you could use the following command:opensslreq-x509-newkeyrsa:4096-keyoutkey.pem-outcert.pem-days365catkey.pem>>cert.pem# generate cert with the private keyDirectory listingBy default, directory listing is disabled, in case you want to enable it, you must provide the flag--dir-list.SpecificationThe server perform 2 basic actions:downloadanduploadfile.Request FieldsIn order to determine the action required in each request, the server examines the following parts of the request:MethodPOST | PUT :: Indicate uploadRest of methods :: Indicate downloadUrlUrl path :: Indicates the path of the desired fileUrl parameters :: Indicates the action parametersBody, which could be:Raw data :: Indicates the content of the fileUrl encoded parameters :: Indicates the action parametersJson data :: Indicates the action parametersHeaders:: Indicates the action parametersCookies:: Indicates the action parameters. Sincepathkey has a special meaning in cookies, it is not possible to use that parameter in these fields.The more relevant parts are those in last positions of the list. That means, for instance, if the Url path indicates the pathindex.html, but there is a parameterpath(in the Url or in the Body) which indicatesother_file.txt, thenother_file.txtwill be selected as the desired path.Key-Value fields (Url, Body, Headers, Cookies)In all those fields which can specified the action parameters, the following values can be provided:action: str :: Determines the actionpath: str :: Indicates the path of the desired fileoffset: int :: (Download) Indicates the starting point for reading a filesize: int :: (Download) Indicates the number of bytes readappend: flag :: (Upload) Indicates if the data should be appended to the desired fileencoding: str :: Indicates the desired encoder use in the actions, actually only base64 is supported (or not encoder)data: str :: (Upload) The data to write into the desired fileMatching keywordsThe key of the key value fields are case-insensitive, then, for instance, is the sameoffsetthatOffsetorOFFSET.In the parameteraction, any value starting byd(such asd,down,download) will match asdownloadaction and any value starting byu(such asu,up,upload) will match asuploadaction.