Monday | 15 APR 2024
[ previous ]
[ next ]

Simple HTTP Server in BASIC

Title:
Date: 2023-07-24
Tags:  http, web, basic

I wrote a simple http server for D3 and ported it to UniVerse as well now. I'm sure it will come in handy at some point.

HTTP.SERVER

A fun project would be to take it all the way to the point where I actually use it to serve my blog. That would definitely be cool. Tie that into my templating engine and the entire site could be written in BASIC.

The biggest drawbacks are that I don't handle all the errors and I definitely don't handle the passing of parameters via the query and form well enough. I have a very simple parsing implementation so it doesn't handle quotes properly.

The first step would be to get it to serve my blog, the second step would be to build out an interactive crud style application. I wonder how fast the BASIC server really is. It calls out to C so it may be quite fast though the string munging may be suboptimal right now.

I ran face first into a bug with the server directly due to differences in D3 and UniVerse. Something to be aware of is how each flavor of pick handles appending null strings through the -1 method. UniVerse will not add the mark while D3 does.

It is therefore better to be explicit when adding nulls so that you don't have issues in UniVerse.

Adding Null Strings - D3 and UV

This is currently a single threaded web server. If I really do want this to work, I'm going to need to write a load balancer that will spawn a server to handle a request. I could possibly spawn the function that I am calling for a route and pass the socket to it however that would require handling the socket in every route that I write.

So many ways to skin a cat.