-
Notifications
You must be signed in to change notification settings - Fork 9
/
oauth2Server.py
49 lines (35 loc) · 1.18 KB
/
oauth2Server.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
#!/usr/bin/env python
import BaseHTTPServer
callback = None
# HTTPRequestHandler class
class testHTTPServer_RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# GET
def do_GET(self):
# Send response status code
self.send_response(200)
# Send headers
self.send_header('Content-type','text/html')
self.end_headers()
# Send message back to client
message = "Hello world!"
# Write content as utf-8 data
print message
print self.path
print "self.path %s" %self.path
CODE_FROM_URL = self.path.split('=')[1]
print "CODE FROM URL %s" %CODE_FROM_URL
callback( CODE_FROM_URL )
return
def run():
print 'starting server...'
# Server settings
# Choose port 8080, for port 80, which is normally used for a http server, you need root access
server_address = ('127.0.0.1', 8081)
httpd = BaseHTTPServer.HTTPServer(server_address, testHTTPServer_RequestHandler)
# httpd.setCallback( videoVimeo.processResoponse )
print 'running server... for 1 response only'
httpd.handle_request()
print "exit from the server"
return
if __name__ == '__main__':
run()