Skip to content

Commit

Permalink
Add HTTP server example
Browse files Browse the repository at this point in the history
  • Loading branch information
ajyoon committed Dec 9, 2016
1 parent c8f49b3 commit f44389e
Show file tree
Hide file tree
Showing 10 changed files with 809 additions and 63 deletions.
1 change: 1 addition & 0 deletions examples/echo.bf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+[,.----------]
85 changes: 85 additions & 0 deletions examples/http/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<html>
<head>
<link rel="stylesheet" href="/main.css">
</head>
<body>
<h1>wtbf?</h1>

<i>
This is a slightly functional HTTP server implemented in
<a href="https://github.com/ajyoon/systemf">systemf</a>, an extension of
the esoteric <a href="https://esolangs.org/wiki/brainfuck">brainfuck</a>
programming language which provides program access to Linux syscalls via
an additional language character "%".
The server can handle GET requests for files relative to the server's
working directory. It's, uh, pretty insecure.
</i>

<hr>

<a href="other_page.html">huh...</a>

<pre>
+++++++++++++++++++++++++++++++++++++++++>+++>>+>++>>+>+>>+><<<<<<<<<<%>>>>>>>>>>+++++++
++++++++++++++++++++++++++++++++++++++++++>+++>>+<<<<<<<<<<<<<[>>>>>>>>>>>>>>+<<<<<<<<<<
<<<<-]>>>>>>>>>>>>>>>+>++++++++++++++++>++>>+++++++++++++++>++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++>>>>>+++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++>+++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++>>>>>>>+>++++++++++++++++<<<<<<<<<<<<<<<<<<<<<<<<<%+[[-]>>>>>>>>>>>>>>>>>>>>>>>>>>++++
++++++++++++++++++++++++++++++++++++++++++++++>++>>+><<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>>>
>>>>>>>>>>>>>>>>>>>+<<<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>>>>>>>>>>>>>>>>+++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++
++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++
+++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++
+++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++
+++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++>+++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++>++++++++++><<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<%>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>><[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>[-]>[-]>[-]>>[-]>[-]>[
-]>[-]>[-]>[-]>[-]>[-]>[-]><<<<<<<<<<<<<<++++++++++++++++++++++++++++++++++++++++>++++>>
+><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>+>>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<>>+>>>++>->-><<<<<
<<<<<<<<<<%[-]>[-]>[-]>[-]<<<+++>+>>+<<<%>>>>>>>>>>>>>>>>>>[>]>>[-]<<<[[-]<]<<<[-]<[-]<[
-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<[-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>[-]+++>[-]>[-]+>[-]++>[-]>
[-]+>[-]+>[-]>[-]+>[-]>[-]+++>[-]>[-]+>>>>>>>>>>>>>>>>>>>>[-]>>[-]++++++++++++++++>[-]>[
-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+]
</pre>

</body>
</html>
9 changes: 9 additions & 0 deletions examples/http/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
h1 {
color: green;
}

body {
padding-top: 200px;
max-width: 630px;
margin: auto;
}
1 change: 1 addition & 0 deletions examples/http/minified
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+++++++++++++++++++++++++++++++++++++++++>+++>>+>++>>+>+>>+><<<<<<<<<<%>>>>>>>>>>+++++++++++++++++++++++++++++++++++++++++++++++++>+++>>+<<<<<<<<<<<<<[>>>>>>>>>>>>>>+<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>+>++++++++++++++++>++>>+++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>>>>>>+>++++++++++++++++<<<<<<<<<<<<<<<<<<<<<<<<<%+[[-]>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++>++>>+><<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>+++++++++<<<<<<<%>>>>[<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+++++++++++++++++++++++++++++++++++++++++++>>>>>>>>>>>>>>>>>>>>>>>++>>++++++++++++++++++++<<<<<<<<<<<<<<<<<<<<<<<<<%[-<<<<<<<<<<+>>>>>>>>>>]>>>>[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<][-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[->>>>+<<<<]>+++>>+>>++>+>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>++>+++++>-><<<<<<<<<<<<%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-]>[>]<[[-]<]<[<]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>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<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++>+>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>>+>+++++++++++++++++>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++>++++++++++>++++++++++><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<%>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>[-]>[-]>[-]>>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]><<<<<<<<<<<<<<++++++++++++++++++++++++++++++++++++++++>++++>>+><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+>>>>>>>>>>>[-<<<<<<<<<<+>>>>>>>>>>]<<<<<<<<<<>>+>>>++>->-><<<<<<<<<<<<<<<%[-]>[-]>[-]>[-]<<<+++>+>>+<<<%>>>>>>>>>>>>>>>>>>[>]>>[-]<<<[[-]<]<<<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[-]>[-]+++>[-]>[-]+>[-]++>[-]>[-]+>[-]+>[-]>[-]+>[-]>[-]+++>[-]>[-]+>>>>>>>>>>>>>>>>>>>>[-]>>[-]++++++++++++++++>[-]>[-]>[-]>[-]>[-]>[-]>[-]>[-]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+]
9 changes: 9 additions & 0 deletions examples/http/other_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<link rel="stylesheet" href="/main.css">
</head>
<body>
<h1>And multiple pages too!</h1>
<a href="index.html">go back</a>
</body>
</html>
Loading

0 comments on commit f44389e

Please sign in to comment.