Single Line Python Webserver

后端 未结 2 1865
囚心锁ツ
囚心锁ツ 2021-02-01 14:20

I seem to remember seeing a single line implementation of a webserver a couple of years ago. I\'m aware of SimpleHTTPServer and it\'s like, and that\'s not it

相关标签:
2条回答
  • 2021-02-01 14:58

    I'm pretty sure you can't have a webserver using sockets and select() on one line of code. Not even using semicolons, you'd have to have some loops and control structures.

    Are you sure this isn't what you are looking for?

    $ python -m SimpleHTTPServer 8000
    Serving HTTP on 0.0.0.0 port 8000 ...
    

    Python 3 version: python -m http.server 8000

    0 讨论(0)
  • 2021-02-01 14:58

    Was it perchance perl? favourite one liners

    perl -MIO::All -e 'io(":8080")->fork->accept->(sub { $_[0] < io(-x $1 +? "./$1 |" : $1) if /^GET \/(.*) / })'
    
    0 讨论(0)
提交回复
热议问题