Shortest functional Web Server Challenge (Any Language)

What?

Yes, this is a code jam for the shortest (bytes) functional (returns a valid HTTP response when visited by an HTTP-compliant browser) web server challenge.

You might already remember the “Shortest node.js express webserver” topic, and this challenge takes it up a notch by allowing any server-side programming language (available on replit) and any type of webserver.

EDIT: there will be TWO WINNERS: One will be for any server, another for a server which returns the text Hello World!

Comment your submission below!

:point_down:

2 Likes

Node.JS

require("express")().listen()
1 Like

@python660 what do you mean by shortest? What are we exactly trying to achieve, are we trying to make a website that takes up the least amount of space? I assume HTML wouldn’t count since it isn’t a programming language.

2 Likes

Shortest means smallest program file size (char count, but on a more technical level, byte count), without additional config elsewhere, while being hosted on replit. Yes, HTML doesn’t count bc it isn’t a user-coded web server, and the webserver behind it is probably too long to count.

1 Like

So PHP or Java or something like that would count? Our goal is just trying to make a website run?

1 Like

yes, that is indeed correct. you could even try to use esolangs!

On a side note, your website just needs to return a valid HTTP response. Additionally, it needs to be able to be run on a repl.

2 Likes

Node

with(require('express')()){use((q,r)=>r.send('Hello World!'));listen()}

Python

host is only needed to run on Replit, otherwise you can save some bytes

__import__('flask').Flask('').run('0.0.0.0')
a=__import__('flask').Flask('');a.route('/')(lambda:'Hello World!');a.run('0.0.0.0')

also:

2 Likes

That AI looks like it’s trying to lengthen it…

Also, are there gonna be two winners for each programming language or just two winners in general?

I don’t know if this would count, but I ran this in PHP → GET HTTP, and the output console said this →

[Sun Dec 24 12:38:39 2023] PHP 8.2.ORC7 Deve Lopment Server (http://0.0.0.0:8000) started [Sun Dec 24 12:38:49 2023] 172.31.196.1:3446
6 Accepted
[Sun Dec 24 12:38:49 2023] 172.31.196.1:3446
6 [200]: GET /
[Sun Dec 24 12:38:49 2023] 172.31.196.1:3446
6 Closing
[Sun Dec 24 12:38:49 2023] 172.31.196.1:4133
0 Accepted
[Sun Dec 24 12:38:49 2023] 172.31.196.1:4133
0 [200]: GET /
[Sun Dec 24 12:38:49 2023] 172.31.196.1:4133
0 Closing
[Sun Dec 24 12:38:49 2023] 172.31.196.1:5363
4 Accepted
[Sun Dec 24 12:38:49 2023] 172.31.196.1:5363
4 [200]: GET /
[Sun Dec 24 12:38:49 2023] 172.31.196.1:5363
4 Closing
[Sun Dec 24 12:38:49 2023] 172.31.196.1:4092
4 Accepted
[Sun Dec 24 12:38:49 2023] 172.31.196.1:4092
4 [200]: GET /
[Sun Dec 24 12:38:49 2023] 172.31.196.1:4092
4 Closing 

I believe it is sending an HTTP request (it also says 200, so it is running). Since a Byte is one character my code would only be 8 Bytes.

https://replit.com/@SalladShooter/ShortestWebServer#index.php


I don’t really know if this counts as this kind of doesn’t feel like it does :person_shrugging:.

in general, because having winners for a specific programming language can get real boring real fast.

3 Likes

i think that this should end on Jan 1, since that’s Replit’s Death Day.

This is the best I got:

require("express")().use((_,s)=>s.end("Hello World!")).listen()
require("express")().listen()

If im looking at this right, you don’t need the extra pair of parentheses. You do around the arguments, but not the one outer that.

1 Like

Yes, you’re correct (for some reason the minifier I used at the end added them)

1 Like

You can put any content in the PHP file and it will serve it. I feel like that falls into

But I’m not sure what really defines a “user coded web server”. Technically all of the express ones aren’t using a user coded server

3 Likes

But running the Repl is really running:

php -S 0.0.0.0:8000 -t 

So your language that you’re using to start a webserver is really Bash, not really PHP

4 Likes

ok, you could consider that a part of the program ig…

1 Like

Yes, you can because the code is supposed to be what is opening the port. Making a file with a file extension isn’t what opens the port. Which, technically the php command is running some other code, but that’s really what’s being triggered in the beginning.

4 Likes

Okay, using http now and saved a few characters:

require("http").Server((_,s)=>s.end("Hello World!")).listen()
2 Likes