-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.py
74 lines (55 loc) · 1.92 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @author: MitsuhaYuki
import os.path
import logging
import tornado.ioloop
import tornado.httpserver
from tornado.web import RequestHandler
log = logging.getLogger()
def setHeader(request):
request.set_header("Access-Control-Allow-Origin", "*")
request.set_header("Access-Control-Allow-Headers", "*")
request.set_header("Access-Control-Allow-Method", "*")
request.set_header("Access-Control-Allow-Credentials", "true")
class MainHandler(RequestHandler):
def get(self):
self.write('emby validation server successfully start')
def post(self):
self.get()
class ValidateDevice(RequestHandler):
def get(self):
setHeader(self)
data = {"cacheExpirationDays": 365, "message": "Device Valid", "resultCode": "GOOD"}
self.write(data)
def post(self):
self.get()
class Validate(RequestHandler):
def get(self):
setHeader(self)
data = {"featId": "", "registered": True, "expDate": "2099-01-01", "key": ""}
self.write(data)
def post(self):
self.get()
class GetStatus(RequestHandler):
def get(self):
setHeader(self)
data = {"deviceStatus": "0", "planType": "Lifetime", "subscriptions": {}}
self.write(data)
def post(self):
self.get()
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
(r"/admin/service/registration/validateDevice", ValidateDevice),
(r"/admin/service/registration/validate", Validate),
(r"/admin/service/registration/getStatus", GetStatus)
])
if __name__ == "__main__":
app = make_app()
http_server = tornado.httpserver.HTTPServer(app, ssl_options={
"certfile": os.path.join(os.path.abspath("."), "cert/server.crt"),
"keyfile": os.path.join(os.path.abspath("."), "cert/server.key"),
})
http_server.listen(443)
tornado.ioloop.IOLoop.current().start()