Fork me on GitHub
#babashka
<
2023-11-16
>
thiru04:11:01

Is there a relatively simple way to handle multipart form data in the babashka world? I'm using http-kit. It looks like ring isn't compatible with babashka so I've been avoiding that. It could handle multipart form data otherwise

johanmynhardt06:11:22

I've been able to use ring successfully in babashka after finding this gem: https://clojurians-log.clojureverse.org/babashka/2023-05-01/1682944876.150579 I have not tried form-params yet, but the parts I use are working well.

👍 1
🙏 1
mmer11:11:21

I managed to get a client side to work with http-kit:

@(http/post url
                    {:multipart [{:name "file" :content content :filename filename}]
                     :oauth-token token
                     :insecure? true
                     :headers {"Content-Type" "multipart/form-data" "Accept" "application/json"}})

Sam13:11:28

In bb.cli there is a nice require function which is described here: https://github.com/babashka/cli#require When I use it I get that and a bunch more:

---- Error --------------------------------------------------------------------
Type:     clojure.lang.ExceptionInfo
Message:  Required option: :ratio
Data:     {:spec {:video {:alias [...]
Location: 
---- Context -----
[...]
---- Stack trace ----
[...]
This is a good error message for me as the developer but it's too much to show users. Is there a way to only show Required option: :ratio or even better Required option: --ratio ?

borkdude13:11:19

I believe you can use :error-fn for this

borkdude13:11:53

There is an example of this in the README

Sam13:11:14

That looks perfect, thank you!

Sam13:11:44

And thank you for babashka!

🙏 1
7tupel16:11:08

Has anyone tried and successfully run a web app with Babashka in combination with htmx and server sent events? It seems I can't figure out how to run a web server (I tried http-kit) to properly setup and communicate to the browser and htmx using server sent events.

borkdude16:11:46

what have you tried so far?

borkdude16:11:50

there is a ring middleware for sse here, I haven't tried it with httpkit + bb, but if you have a work-in-progress little project, I could give it a stab locally https://github.com/kumarshantanu/ring-sse-middleware/blob/master/src/ring_sse_middleware/adapter/http_kit.clj

borkdude16:11:27

Who is here familiar with python argparse? I'm trying to figure something out, welcome in #C02FBBU61A9