CXP / HTTP Samples

Announcements about new features or events.
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

CXP / HTTP Samples

#1 Post by rdonnay »

Here is a set of sample files to show how to create your own Web Server.

Unzip the attached file into your \exp20\samples\web20 folder but first delete all files that are already in that folder. Also, delete \exp20\samples\web and \exp20\cxp folders. These should have been cleaned up with the build 261 release.

CxpHttpServer.Exe is a Web Server that utilizes the HttpEndPoint() and WebHandler() classes of Xbase++ 2.0.

This is a simple but powerful framework for a Web Server that can be used for almost any purpose.
No other web server is required. No IIS or Apache.
It will handle all file types that are normally handled by any web server and in addition it will compile .CXP pages.

The default port is 8080 in this sample.
To test any of the methods, start your web browser and enter the following URLs:

Code: Select all

http://localhost:8080/index.html
http://localhost:8080/test/gettime
http://localhost:8080/test/echovars?a=1,b=2,c=3
There is an error handler that will return the error information to the web browser. To see how this works enter the following URL:

Code: Select all

http://localhost:8080/test/crash
Coding of Methods is incredibly simple by creating sub classes that inherit from CustomWebHandler.

Example:

Code: Select all

CLASS Test FROM CustomWebHandler

EXPORTED:
INLINE METHOD getTime

LOCAL cThreadId, cResponse := ""

cThreadId := AllTrim(Str(ThreadId()))

cResponse += "<!DOCTYPE html>"
cResponse += "<html>"
cResponse +=   "<head><title>"+ProcName()+"</title></head>"
cResponse +=   "<body>"
cResponse +=     "<h1>Current Time:</h1>"
cResponse +=     "<p>"+Time()+" (HH:MM:SS)</p>"
cResponse +=     "<small>By thread: "+cThreadId+"</small>"
cResponse +=   "</body>"
cResponse += "</html>"

RETURN cResponse

ENDCLASS
There is also a SendMail() function that will send emails out to a SMTP server. It supports SSL for sending via Gmail or other secure servers.

* =======================

EmailVerify is a program written for Bobby Drakos that is used to verify that the Medallion system has a correct email address for each driver.

This service sends an email to the address on file for each driver. If the driver receives the email he will click on the URL in the email to completethe verification.

AddEMail

This method sends the email and writes the driver hack number, email address, date/time and PENDING status to MNEVN.DBF.

VerifyEmail

This method is called when the driver clicks on the URL in the received email. The driver has 24 hours to verify the email or he will receive a response to call the office. The verification updates the status in MNEVN.DBF and writes VERIFIED status to MNEVN.DBF

CleanUp

This method will delete all records in MNEVN.DBF that have a status of DENIED and are older than 24 hours. It will also send an email to the Transit office for each DENIED record stating that the address could not be verified.


Usage

The Medallion program would simply send a URL to localhost to start the verification process.

Example:
DC_SpawnUrl("http://localhost:8080/VerifyEmail/AddEm ... garage.com")
Attachments
Web20.zip
(99 KiB) Downloaded 892 times
The eXpress train is coming - and it has more cars.

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CXP / HTTP Samples

#2 Post by rdonnay »

There was an error in the readme.txt file.

Make the following change at the last line:

Code: Select all

DC_SpawnUrl("http://localhost:8080/VerifyEmail/AddEmail?Hack=123456&Email=joe@joesgarage.com")
The eXpress train is coming - and it has more cars.

Zdeno Bielik
Posts: 147
Joined: Thu Jan 28, 2010 9:24 am
Location: Nitra, Slovakia
Contact:

Re: CXP / HTTP Samples

#3 Post by Zdeno Bielik »

Hi Roger,

new examples and source codes look great/fantastic.
Unfortunately, this new version of CxpHttpServer I cannot compile without removing line
#pragma library(‘asinet10.lib’)…
There is no this problem with previous version http://bb.donnay-software.com/donnay/vi ... =15&t=1345

I have only Foundation subscription, not Professional, so, I think this problem now...
Is it possible for you optionaly by e.g. any parameter build also version without needed dll/lib from profi version,
because I try comment e.g. SendMail function, but it still doesn’t want to start…
I have MarshallSoft lib, so I can use my version of SendMail function for sending eMails.

TIA & Regards
Zdeno

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CXP / HTTP Samples

#4 Post by rdonnay »

If you only have the foundation, then you will need to remove the SendMail() function.
It uses the AsiNet library for SMTP.
The eXpress train is coming - and it has more cars.

Zdeno Bielik
Posts: 147
Joined: Thu Jan 28, 2010 9:24 am
Location: Nitra, Slovakia
Contact:

Re: CXP / HTTP Samples

#5 Post by Zdeno Bielik »

Hi Roger,

ok, it works now - I replaced/call my version of SendMail function (I added/linked MarshallSoft library into project file) – super.

But there is any next little problem:
Examples 2, 3, 4 from index.html work ok, but when I want try first one „Run CxpInfo.cxp“, nothing happens on pc, where is only CxpHttpServer running (no Apache or IIS instaled)…

On pc, where is IIS installed, it works only when I call it direct from web-browser
and only next one line is displayed and not all informations about system
„C:\inetpub\wwwroot\ds\donnay\cxp-application\cxpinfo.cxp.dll“
Why? Where is problem?

Zdeno

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CXP / HTTP Samples

#6 Post by rdonnay »

Delete all the dlls in the cxp-application sub folder.

I forgot to do this.
The cxpinfo.cxp.dll is created the first time that CXPINFO.CXP is loaded.
The eXpress train is coming - and it has more cars.

Zdeno Bielik
Posts: 147
Joined: Thu Jan 28, 2010 9:24 am
Location: Nitra, Slovakia
Contact:

Re: CXP / HTTP Samples

#7 Post by Zdeno Bielik »

Roger,

hmmm , ok, I deleted all files
but it works now only in case, when I first run CxpInfo.cxp in web-browser on pc, where is IIS installed
CxpInfo.cxp.dll is then created and this already created file can now CxpHttpServer display yet
it looks that CxpHttpServer can’t create that file
Why?

Zdeno

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CXP / HTTP Samples

#8 Post by rdonnay »

I have recently discovered issues with CXP pages and HttpEndpoint that make me think this is not ready yet.

I will be discussing this with Steffen at our devcon in 1 month.

I want to use this as much as you do so I will be pressing him to make this work.
The eXpress train is coming - and it has more cars.

Zdeno Bielik
Posts: 147
Joined: Thu Jan 28, 2010 9:24 am
Location: Nitra, Slovakia
Contact:

Re: CXP / HTTP Samples

#9 Post by Zdeno Bielik »

Hi Roger,

followed your examples in \samples\cxp folder and your help of course,
I already successfully made/transform some my code from Xbase++/eXpress++ PRG to CXP versions.
But now I step-by-step started move it to CxpHttpServer versions,
and I have some little problems, especially with Form and Customers examples.

Please, can your add CHS versions of that examples from \cxp to the \web20 too?

Many thanks
Zdeno

User avatar
rdonnay
Site Admin
Posts: 4728
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: CXP / HTTP Samples

#10 Post by rdonnay »

Please, can your add CHS versions of that examples from \cxp to the \web20 too?
I don't understand. What is CHS?
The eXpress train is coming - and it has more cars.

Post Reply