/
main.py
executable file
·59 lines (54 loc) · 1.67 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# coding: utf-8
import wsgiref.handlers
def application(environ, start_response):
start_response('200 OK', [('Content-type','text/html')])
html = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>JSON Services</title>
<style type="text/css">
body {
font-family: "News Gothic MT", Arial;
}
h1 {
color: #0F48B0;
}
h2 {
margin-top: 2em;
}
h2 a {
color: #1695A3;
}
h2 a:visited {
color: #225378;
}
h2 a:after {
content: " »";
}
</style>
</head>
<body>
<h1>JSON Services</h1>
<p>
Providing JSON Web Services for Unit Testing.
</p>
<div class="service">
<h2><a href="/echo">/echo</a></h2>
Parsed, structured JSON object representing the HTTP Request.
</div>
<div class="service">
<h2><a href="/time">/time</a></h2>
Returns the current unix timestamp.
</div>
<div class="service">
<h2><a href="/sleep">/sleep</a></h2>
Takes a 'seconds' query parameter and returns a simple text
response after sleeping for the given number of seconds.
</div>
</body>
</html>
"""
return [html]
wsgiref.handlers.CGIHandler().run(application)