Send multiple files in a response with Cherrypy.

Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Send multiple files in a response with Cherrypy.

Jose Henrique S Junior
Ok guys, I have a server, written in Cherrypy, and the code for receiving files and saving them to disk is ready.

Now I am trying to respond to a GET query, with a list of responses, and some files attached to each of those responses. I've been looking on the internet for it, but I must not be using the right words on my search, because I haven't got any hits.

Any ideas on where to look or how to proceed?

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/0d28bd12-ce86-43ea-a29d-60237c5095a6n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Send multiple files in a response with Cherrypy.

David Allouche
Hello,

You should start with an entry level book on web programming. Maybe this one: https://www.oreilly.com/library/view/http-the-definitive/1565925092/

More specifically, what you say you are trying to do makes no sense in the HTTP protocol, where one request produces one response.

On 3 Nov 2020, at 01:03, 'Jose Henrique S Junior' via cherrypy-users <[hidden email]> wrote:

Ok guys, I have a server, written in Cherrypy, and the code for receiving files and saving them to disk is ready.

Now I am trying to respond to a GET query, with a list of responses, and some files attached to each of those responses. I've been looking on the internet for it, but I must not be using the right words on my search, because I haven't got any hits.

Any ideas on where to look or how to proceed?

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/0d28bd12-ce86-43ea-a29d-60237c5095a6n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/3F791E7D-3AE4-463D-9CD3-3BA3F7058B52%40allouche.net.
Reply | Threaded
Open this post in threaded view
|

Re: Send multiple files in a response with Cherrypy.

Sviatoslav Sydorenko (@webknjaz)
Hey Jose,

> > On 3 Nov 2020, at 01:03, 'Jose Henrique S Junior' via cherrypy-users <[hidden email]> wrote:
> > Now I am trying to respond to a GET query, with a list of responses, and some files attached
> > to each of those responses. I've been looking on the internet for it, but I must not be using the
> > right words on my search, because I haven't got any hits.
> >
вт, 3 лист. 2020 о 10:37 David Allouche <[hidden email]> пише:
> You should start with an entry level book on web programming. Maybe this one: https://www.oreilly.com/library/view/http-the-definitive/1565925092/
>
> More specifically, what you say you are trying to do makes no sense in the HTTP protocol,
> where one request produces one response.
>

as David wrote, it's important to understand how HTTP works,
especially given that CherryPy is
a microframework where you're working with low-level stuff more than
in high-level frameworks.

It sounds like you want to implement a list operation typical to CRUD.
The way it's usually solved
is implementing some sort of and API that responds with structured
data like JSON (see
also REST). When the client sends an API request over HTTP, it gets a
list of pointers to files
(often accompanied with some extra metadata like names/dates etc.)
Then, the client parses that list, extracts the URLs to files, and
issues a series of separate
subsequent HTTP requests in order to download those files.

Of course, it's technically possible to embed files into that first
HTTP response but it's not really
common. You could pack different chunks of data using the multipart
MIME type or come up
with your own serialization for embedding the data. Although, be
prepared to implement proper
parsing on the client.

P.S. It'll still be one HTTP response to one HTTP request. Be aware
that CherryPy supports
HTTP/1.1 and not HTTP/2. So when you'll learn about HTTP, make sure
you understand how
this version works.


--
Cheers,
Sviatoslav.

---
https://useplaintext.email/
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments
---

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/CAFYONRBXaU2d33ERLvyUmcwaLDiDQZFrXG26brr83c8nubSOvg%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Send multiple files in a response with Cherrypy.

Michiel Overtoom
In reply to this post by Jose Henrique S Junior
Hi,

> the code for receiving files and saving them to disk is ready.

I once made a webapp which had to let a visitor download multiple files in one click. I realized this by putting them in a ZIP file, and serve that as a response. AFAIK it's not possible to have multiple files served to the browser with a single request.

Greetings,

--
"You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/55FF5A07-A5CF-4E1A-AA7B-BE7148562DE3%40xs4all.nl.
Reply | Threaded
Open this post in threaded view
|

Re: Send multiple files in a response with Cherrypy.

ingoogni
One could use SSE to tell / trigger the client to download what from
where. Kind of one request multiple replies.

I'd prefer a Zip.


On 4-11-2020 09:16, Michiel Overtoom wrote:

> I once made a webapp which had to let a visitor download multiple files in one click.

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/cherrypy-users/a4ab4378-2f4d-7d11-3740-aef1d6644b3c%40gmail.com.