Author Topic: How to print html code?  (Read 7879 times)

votan

  • Guest
How to print html code?
« on: February 21, 2010, 07:13:31 AM »
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

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: How to print html code?
« Reply #1 on: February 21, 2010, 09:28:18 AM »
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, ...