What is it
It’s a micro web server that features php and web service extension
Build
Dependencies: Poco c++ libraries
For linux:
[cc lang=”bash”]
~/bashttp $ rm -rf build/
~/bashttp $ mkdir -p build/debug
~/bashttp $ cd build/debug/
~/bashttp $ cmake ../.. -DCMAKE_BUILD_TYPE=Debug
~/bashttp $ make
[/cc]
For windows use cmake-gui from http://www.cmake.org/.
How to run
To run it
[cc lang=”bash”]
~/bashttp $ bashttp 8888 doc_root
bashttp listening on 127.0.0.1:8888
[/cc]
Where 8888 is the port and ‘doc_root’ is the document root directory
To stop it simply press ctr+c
Configuration and test files
doc_root: document root directory
doc_root/index.html: html test page
doc_root/index.php: php test page
mime.conf: mime configuration. Must be in execution directory.
/etc/alternatives/php-cgi: php binary for linux
php.cgi.exe: php binary for windows. Must be in execution directory.
😈 Execute shell from browser 😈
Write a new web service
Example of service that would be called as ‘http://server/newservice’:
class NewService : public MiniWebService
{
public:
virtual void exec(const Poco::Net::HTTPServerRequest& request,
std::map
Poco::Net::HTTPServerResponse& response,
Poco::Net::StreamSocket& sock,
Poco::Net::HTTPServerSession& session)
{
std::ostream& ostr = response.send();
ostr << "it works.";
ostr.flush();
}
static std::string name() { return "newservice"; }
};
Where:
- name() method returns the web service identifier as seen in url
- exec(...) implements the web service.
Add it to server before start it
[cc lang=”cpp”]
std::shared_ptr svc(new NewService());
server.addService(NewService::name(), svc);
[/cc]

