askrobots / postblob Public

An experimental web framework where PostgreSQL does everything: routing, HTML, file storage, jobs and sessions.

0 downloads

postblob/fix_homepage_html.sql
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/postblob.git
HTTPS
https://gitstable.com/git/askrobots/postblob.git
SSH
ssh://git@gitstable.com:2222/askrobots/postblob.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 docs: Add screenshots to README ae44e69 1 year, 1 month ago History
fix_homepage_html.sql · 928 bytes · 21 lines
1-- Fix homepage to return HTML mime type instead of JSON
2-- The issue is in the handle_request function - it needs to set html: true in the response
3
4UPDATE code_files
5SET content = regexp_replace(
6 content,
7 -- Find the line that returns the homepage response
8 'RETURN jsonb_build_object\(\s*''status'', 200,\s*''headers'', jsonb_build_object\(''Content-Type'', ''text/html''\),\s*''body'', v_html\s*\);',
9 -- Replace with version that includes html flag
10 E'RETURN jsonb_build_object(\n ''status'', 200,\n ''headers'', jsonb_build_object(''Content-Type'', ''text/html''),\n ''body'', v_html,\n ''html'', true\n );',
11 'g'
12),
13version = version + 1,
14updated_at = now()
15WHERE path = 'functions/handle_request.sql';
16
17-- Hot reload the function
18SELECT hot_reload('functions/handle_request.sql');
19
20-- Return status
21SELECT 'Homepage fixed to return HTML!' as result;