Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 11:06
    straight-shoota edited #12547
  • 11:05
    straight-shoota opened #12547
  • 11:05
    straight-shoota labeled #12547
  • 11:05
    straight-shoota labeled #12547
  • 10:24
    straight-shoota closed #11354
  • 10:24
    straight-shoota closed #12536
  • 10:24
    straight-shoota closed #12494
  • 10:22
    straight-shoota ready_for_review #12541
  • 10:22
    straight-shoota synchronize #12541
  • 10:22
    straight-shoota closed #12539
  • 10:21
    straight-shoota closed #12290
  • 10:21
    straight-shoota closed #12537
  • 10:21
    straight-shoota edited #12537
  • 10:20
    straight-shoota milestoned #12545
  • 10:20
    straight-shoota milestoned #12545
  • 05:44
    HertzDevil edited #12546
  • 05:44
    HertzDevil labeled #12546
  • 05:44
    HertzDevil labeled #12546
  • 05:44
    HertzDevil opened #12546
  • 05:20
    HertzDevil labeled #12545
Filip Samuel
@1337M0nst3r
why doesn't this work?
a = 2/1
p! a # prints 2.0
sorry, I meant
p! a.round # prints 2.0
George Dietrich
@Blacksmoke16
what would you expect it to be?
Ary Borenszweig
@asterite
I guess an int instead of a float
moe
@moe:busyloop.net
[m]
fixed 😛
George Dietrich
@Blacksmoke16
2 // 1 :wink:
Benjamin Wade
@RespiteSage
"Proposal to add Float#rount to the standard library"
Also, serious question: (x / y).round.to_i is different than x // y, right?
George Dietrich
@Blacksmoke16
they're the same if #round happens to round down
Benjamin Wade
@RespiteSage
Yeah, I see.
Rounding to even is the default for #round, right?
So I guess maybe they're the same all the time if you're using RoundingMode::TO_ZERO?
I'm getting too wrapped up in this..
George Dietrich
@Blacksmoke16
or like (x / y).floor.to_i yea
From IRC (bridge bot)
@FromIRC
<frojnd> Hi there.
<frojnd> I would like to build a simple file server with Kemal. I am looking at apps that are built with Kemal so I can see what's the file structure of source code. Any good examples?
moe
@moe:busyloop.net
[m]
From IRC (bridge bot)
@FromIRC
<frojnd> @moe thank you will take a look right away
3 replies
From IRC (bridge bot)
@FromIRC
<frojnd> Hm hm
<frojnd> But when I try to upload some file I get: Exception: Cannot extract form-data from HTTP request: could not find boundary in Content-Type (HTTP::FormData::Error)
moe
@moe:busyloop.net
[m]
sounds like you'e posting with the wrong content-type
From IRC (bridge bot)
@FromIRC
<frojnd> What is the correct content-type ?
moe
@moe:busyloop.net
[m]
multipart/form-data
From IRC (bridge bot)
@FromIRC
<frojnd> It's a progress but now I see: Exception: Missing hash key: "image1" (KeyError)
<frojnd> curl -v -F image1=value1 upload=@bla.txt http://0.0.0.0:3000/upload
<frojnd> Not sure what that error means
moe
@moe:busyloop.net
[m]
sorry, not sure either (i'm not very familiar with kemal)
From IRC (bridge bot)
@FromIRC
<frojnd> Ha, was looking at wrong code
<frojnd> https://kemalcr.com/guide/ File Upload
From IRC (bridge bot)
@FromIRC
<frojnd> Any ideas how to access public folder?
<frojnd> Like I have uploads there with some files... I would like to access those files within crystal
George Dietrich
@Blacksmoke16
moe
@moe:busyloop.net
[m]
George Dietrich
@Blacksmoke16
nice! congrats!
From IRC (bridge bot)
@FromIRC
<frojnd> @Blacksmoke16 yeah, but when I write get "/uploads" do ... end how do I list everything inside public/uploads ?
George Dietrich
@Blacksmoke16
would have to write something to do that
https://crystal-lang.org/api/HTTP/StaticFileHandler.html provides a way to render an index listing (like you'd get going to that directory in chrome), but not sure if kemal has something similar/equivalent
looks like theres a config for dir_listing you have to enable?
er a few sections down
From IRC (bridge bot)
@FromIRC
<frojnd> @Blacksmoke16 just adding serve_static({"gzip" => true, "dir_listing" => true}) inside get "uploads" do ... end did the trick
<frojnd> However if I wanted to add more content to a listed file there like upload date etc would I have to write my own StaticFileHandler ?
George Dietrich
@Blacksmoke16
e.g. your own template provided to ECR.def_to_s