Support > General Discussions

How to print html code?

(1/1)

votan:
Is there an easy way to print html code (using sbhttpd)? So that the browser displays all the html code instead of interpreting it?
Current solution would be to parse all html and replace characters like "<>" with their chr-codes to make it work.... but there is propably an easier way to just escape that!?

Support:
View source in your browser.

The sbhttpd server executes programs. HTML is string data to SB and whatever you send to the browser is what will be displayed in the browser.

If you asking if you can view SB code in the browser the answer is no. SB doesn't parse embedded HTML scripts like php (which is a hackers dream) but executes a CGI binary program.

You could make a copy of your SB source outside the SB proxy directory and add a .txt to the end. This way the browser sees the file as text and displays it verbatim.

Hint:

I find it easier to wrap static HTML/JavaScript text in strings and PRINT them in my output section of my script after any preprocessing that needs to be done. SB also allows (like Python) to encapsulate multiple lines of text using """ (three quotes) and it will send that string to the browser as is with line breaks, tabs, ...

Navigation

[0] Message Index

Go to full version