My Hacker Blog

Mandatory First Post

Finally, I took 1h to create a simple markdown blog website. Now there should be no excuses left to not document something. Anyhow, this is how you can replicate this if you want:

Setup

install dependencies

apt install gunicorn python3-markdown python3-markdown2

setup project structure

mkdir wwwroot
mkdir wwwroot/posts
mkdir wwwroot/templates
wwwroot/
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ posts/
โ”‚   โ”œโ”€โ”€ first-post.md
โ”‚   โ””โ”€โ”€ another-post.md
โ””โ”€โ”€ templates/
    โ”œโ”€โ”€ base.html
    โ”œโ”€โ”€ index.html
    โ””โ”€โ”€ post.html

create service configuration

nano /etc/systemd/system/blog-site.service

configuration content

[Unit]
Description=My Blog-Site

[Service]
Type=simple
User=web
ExecStart=/bin/bash /opt/Blog-Site/start_server.sh
WorkingDirectory=/opt/Blog-Site
Restart=on-failure


[Install]
WantedBy=multi-user.target

start service

systemctl daemon-reload
systemctl enable blog-site.service
systemctl start blog-site.service
systemctl status blog-site.service

setup Cloudflare reverse proxy

  • buy a domain name
  • create a cloudflare tunnel, set cloudflare as DNS provider, see here
  • go to cloudflare > networks > connectors, select your tunnel > edit
  • go to Published application routes > add a published application route, example see below
blog.your.domain -> http://localhost:9004

Disclaimer

The initial structure was surely not built by AI. Ain't no one got time to write HTML and CSS nomore.

Result

A simple blog website with code syntax highlighting, without any JavaScript, f*ck JavaScript.
Also, it is quite fast. I hate websites that take more than 100ms to load.

Python Example

def test():
    print("abcd" + 123)
    return 1

C++ Example

int main(int argc, char[] argv) {
    int a = 2;
    std::cout << "test" << argv[a] << "\n";
}

About Me

GitHub

LinkedIn

/dev/null