Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Power of C++ - Developing a Portable HTTP Server with Python Interpreter using Boost, TinyXML

, 1 Jun 2008
This article describes portable networking library (ahttp) and small HTTP server - result of modern C++ programming approaches investigation
ahttpserver_demo.zip
ahttpserver_demo
ahttpserver.exe
boost_python-vc80-mt-1_34_1.dll
python_handler.dll
web
images
icon_dir.gif
icon_file.gif
icon_virtual_dir.gif
python
favicon.ico
print.pyhtml
ahttpserver_src.zip
ahttplib
aconnect
ahttp
http_header_read_check.inl
tinyxml
ahttpserver
out
server.config.ubuntu
web
images
icon_dir.gif
icon_file.gif
icon_virtual_dir.gif
python
python_handler
wrappers.inl
module.inl
server.config.win-debug
server.config.win-release
favicon.ico
print.pyhtml
categories = [ ("Arhitecture", 1),
    ("C & C++", 2),
    ("Common programming. Algorithms", 3),
    ("Components docs", 4),
    ("Database", 5),
    (".NET", 6),
    ("Game development", 7),
    ("GUI", 8),
    ("Java", 10),
    ("Linux programming", 11) ]
    
cat_by_id = {}
for cat in categories: cat_by_id [ str(cat[1]) ] = cat[0]

# format output
_get = http_context.request.get
id = ""
if "id" in _get: 
    id = _get["id"]

body = "Virtual path: %s" % http_context.virtual_path
    
if id != "":
    parentPath = http_context.virtual_path
    if (parentPath.endswith ('/')): parentPath = parentPath.rstrip ('/')
    parentPath = parentPath[0 : parentPath.rfind ('/') +1]

    if id in cat_by_id:
        sel_cat = cat_by_id[id]
    else:
        sel_cat = "Unknown"
    
    body += "<hr/>Selected: <b>%s</b>" % (sel_cat)
    body += "<br /><br /><a href=\"%s\">Go to categories list</a><br/>" % parentPath
else:
    body += "<br/><h1>Categories</h1>"
    for cat in categories: 
        body += "<a href=\"%d\">%s</a><br/>" % (cat[1], cat[0])   


    

template = """<html><head>
<title>Mappings test</title>
<style> BODY { padding: 10px; margin: 10px; font: 10pt Tahoma, Arial; color: #000;} 
    H1 {font-size: 12pt; font-weight: bold; } 
    HR {height:1px; border: 1px solid #333; color: #333;} 
    TABLE {font-size: 100%;} 
</style></head>
<body>
{body}
 <hr />
 </body></html>"""
   
http_context.write ( template.replace("{body}", body) )

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Artem Kustikov
Software Developer (Senior)
Belarus Belarus
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 1 Jun 2008
Article Copyright 2008 by Artem Kustikov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid