Qub (pronounced "cube") is a CLI that generates a web server and framework for building websites in QB64 -- a more modern variant of QBasic.
(Note: macOS & Linux only)
To get started, set up your qub
alias first. This is the quick & easy way:
alias qub="source <(curl -sSL https://raw.githubusercontent.com/jamonholmgren/qub/main/src/cli.sh)"
However, some are understandably uncomfortable with running a script directly from the internet. If you'd like to run it locally, here's how:
Now, you should be able to run the CLI:
qub
qub --version
qub --help
qub create
qub update
Windows Support: Qub has only been tested on macOS and Linux. It might work on Windows WSL (Windows Subsystem for Linux) or Git Bash on Windows. If you want to help test and make it run on Windows, please open an issue or PR!
To create a website, run qub create
and follow the prompts:
qub create
It'll ask you for your domain name (e.g. jamon.dev) which doubles as your project's folder name. It will also ask if you want to install QB64 (I recommend you do).
When done, you can CD into the new folder and run ./bin/build
to build the website. Then, run ./server
to start the web server. Visit http://localhost:6464/ to view the website.
Your new website has the following folder structure:
bin
qub
server.bas
qub.conf
web
pages
home.html
contact.html
static
scripts.js
styles.css
layout.html
README.md
This is the Qub web server. You can periodically update it by running qub update
. Note this will blow away any modifications you've made, so be careful!
Qub's web server was originally based on Yacy by SmokingWheels, but has been heavily modified since. It comes with a number of features:
<!--$YEAR-->
in web/layout.html, etc)It does not (and probably won't) support HTTPS or HTTP2. I recommend putting CloudFlare in front of it in production (more in the deploy guide below).
In the web
folder, you'll find a layout.html file.
This is the standard layout for your website, and includes your html's head and body sections, with placeholder comments for dynamic content like what page is being rendered.
<!DOCTYPE html>
<html>
<head>
<!-- other stuff -->
<title><!--$TITLE--></title>
</head>
<body>
<!-- whatever you want to wrap your page content with -->
<!--$BODY-->
<!-- footer content, etc -->
</body>
</html>
This is where your website's pages go. Each page is an HTML file. You can add as many as you want, and they'll be routed automatically (minus the .html extension).
So, for example, if you add web/pages/links.html
, it will be available at example.com/links
. If you add a folder it'll route to that as well, so web/pages/blog/2023.html
will be available at example.com/blog/2023
.
You'll put your static files here -- CSS, JS, images, fonts, etc. They'll be served at example.com/static/
(e.g. example.com/static/styles.css
). Any image files, fonts, PDFs, etc will be served as binary files (e.g. example.com/static/logo.png
).
If you want to customize your 404 page, you can do so by editing web/pages/404.html
. This is shown if the router is unable to find a page for the given URL. It'll also respond with the proper 404 status code.
COMING SOON!
When I was twelve, I built my first game in QBasic -- and kept building games and small apps (we called them "programs" in those days) for years. I have a lot of nostalgia and a special place in my heart for QBasic.
A few years ago, I was talking about rebuilding my website in something different, just for a fun challenge, and my friend Mark Villacampa said "do it in BASIC you coward!". I took on the challenge and built jamon.dev in QB64.
Once I had a working website, I realized that I wanted to make it easier for other people to build websites in QB64, so I started building Qub, aided by @knewter who is another QBasic fan from way back.
Qub is not particularly important to modern technology in the grand scheme of things, but it's been a blast to work on. I hope you enjoy it!
I'd love to build more QBasic-powered server capabilities. I'm still learning how to utilize QB64 -- for example, in old QBasic, you couldn't include external files, but in QB64 you can.
MIT -- see LICENSE for details.
QB64 is licensed under the MIT license.