Skip to content

Commit

Permalink
notary_http - Serve a static index page with explanation info for vis…
Browse files Browse the repository at this point in the history
…itors

Hopefully this will help orient visitors who stumble across a network notary.
Might even encourage people to get involved!
  • Loading branch information
daveschaefer committed Jul 17, 2012
1 parent 394873b commit ae419c7
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
4 changes: 4 additions & 0 deletions notary.cherrypy.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
[/favicon.ico]
tools.staticfile.on = True
tools.staticfile.filename = "img/perspectives.ico"

[/img]
tools.staticdir.on = True
tools.staticdir.dir = "img"
9 changes: 8 additions & 1 deletion notary_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NotaryHTTPServer:
DEFAULT_WEB_PORT=8080
ENV_PORT_KEY_NAME='PORT'
STATIC_DIR = "notary_static"
STATIC_INDEX = "index.html"

def __init__(self):
parser = argparse.ArgumentParser(parents=[ndb.get_parser(), keygen.get_parser()],
Expand Down Expand Up @@ -160,8 +161,14 @@ def get_xml(self, service_id):

@cherrypy.expose
def index(self, host=None, port=None, service_type=None):
if (host == None or port == None or service_type == None):
if (host == None and port == None and service_type == None):
# probably a visitor that doesn't know what this server is for.
# serve a static explanation page
path = os.path.join(cherrypy.request.app.config['/']['tools.staticfile.root'], self.STATIC_INDEX)
return cherrypy.lib.static.serve_file(path)
elif (host == None or port == None or service_type == None):
raise cherrypy.HTTPError(400)

if service_type != "1" and service_type != "2":
raise cherrypy.HTTPError(404)

Expand Down
Binary file added notary_static/img/perspectives-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions notary_static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<html>
<head>
<title>Perspectives Network Notary Server</title>
<style type='text/css'>
body {
background-color: white;
color: #333333;
padding: 20px;
margin: 0;
line-height: 20px;
font-size: 14px;
font-family: Arial, sans-serif;
}

.section.info {
color: #222222; }

.section.info h1 {
font-size: 22px;
background-color: #99ccff;
padding: 10px 10px 10px 10px;
margin: 0;
overflow: hidden; }

.section.info .box {
border: 4px solid #99ccff;
padding: 20px 20px 20px 20px; }

.section.info .box a {
color: #6666cc; }

.section.info img {
vertical-align: text-bottom;}
}
</style>
</head>

<body>
<div class='container'>
<div class='section info'>
<h1><IMG SRC="img/perspectives-logo.png" TITLE="Perspectives" width="32" heigh="32" />&nbsp;Perspectives Network Notary Server</h1>
<div class='box'>
<p>This is a Perspectives 'network notary' server. It collects and shares information on SSL certificates from around the internet.</p>
<p>For more information see <a href="http://perspectives-project.org">http://perspectives-project.org</a>.</p>
</div>
</div>
</div>
</body>
</html>

0 comments on commit ae419c7

Please sign in to comment.