Main Board > Web Services

EZWeb Server

(1/2) > >>

Jeffrey Ferreira:
Hello List,
I was able to get ezweb server running and rendering static html pages.
when i use print(%PRINT_FN) - it seems to return a file
i'm trying to create a dynamic html page on the fly

so if user goes to localhost:8080/part=A123

i want to return an html page but i want to modify some of the info...
does anyone know how i can do that....
thanks
jeff

Mike King:
You likely just need to format your output as an HTML page.  By default the system will assume a content-type of text/html.

For example (Note to make sure this came thru I replaced less than and greater than with { and } respectively):

  PRINT (%PRINT_FN) "{!DOCTYPE html}"
  PRINT (%PRINT_FN) "{html}{body}"
  OPEN (1,IOL=*) "products"
  READ (1,key=PART$,ERR=BadPart) part$, desc$, price
  CLOSE (1)
!
  PRINT (%PRINT_FN) "{table}"
  PRINT (%PRINT_FN) "{tr}{th}Part{/th}{th}Description{/th}{th}Price{/th}{/tr}
  PRINT (%PRINT_FN) "{tr}{td}"+part$+"{/td}{td}"+desc$+"{/td}{td}"+str(Price)+"{/td}{/tr}"
  PRINT (%PRINT_FN) "{/table}"
  PRINT (%PRINT_FN) "{/body}{/html}"

Jeffrey Ferreira:
Hi Mike when i do this it seems to go into the Downloads Folder and when i open it , it is my program but in an encrypted format [pvxprg]

Mike King:
Jeff,

What is the name of your program and what is the exact URL you are using?

The program should have a .pxp or .pvp suffix on its file name. 

For example:

Assuming your URL is:     http://localhost:8080/program1.pxp?part=A123

Then your program should be in the file "program1.pxp" on the server.

Jeffrey Ferreira:
Hi Mike

the program name is parts.pxp
i'm using http://localhost:8080/parts.pxp
i'm not using a query string at this time
it is an older version of pxplus 10.2

here is my program parts.pxp

0010 print (%PRINT_FN)"<html>"
0020 print (%PRINT_FN)"<head>"
0030 print (%PRINT_FN)"</head>"
0040 print (%PRINT_FN)"<body>"
0041 print (%PRINT_FN)"<h1>Hello Jeff</h1>"
0042 print (%PRINT_FN)"</body>"
0043 print (%PRINT_FN)"</html>"
0050 end

i'm pretty sure it is finding my program because in firefox here is what it shows on screen

[Pvxprg]�Ù���Õ�½�cai         ����������������������������������������c1’þ���������������X9�������Ù���Õ���½�������Ù��������������������������������������������������������������������������������������������������������������������������������������������€�'�   text/htmlÿ��
Ç$€&�<html>ÿ��Ç$€&�<head>ÿ��Ç$€&�</head>ÿ��(Ç$€&�<body>ÿ��)Ç$€&�<h1>Hello Jeff</h1>ÿ��*Ç$€&�</body>ÿ��+Ç$€&�</html>ÿ��2¦ÿ�ýè¦ÿ
%CONTENT_TYPE   %PRINT_FN���

Navigation

[0] Message Index

[#] Next page

Go to full version