89 lines
3.0 KiB
Python
89 lines
3.0 KiB
Python
import time
|
|
|
|
from eaapi import Type
|
|
|
|
from ..server import EAMServer
|
|
from ..model import ModelMatcher
|
|
|
|
|
|
server = EAMServer("http://127.0.0.1:5000", verbose_errors=True)
|
|
|
|
|
|
@server.handler("pcbtracker", "alive")
|
|
def pcbtracker(ctx):
|
|
ecflag = ctx.call.xpath("@ecflag/pcbtracker")
|
|
|
|
ctx.resp.append(
|
|
"pcbtracker",
|
|
status="0", expire="1200",
|
|
ecenable=ecflag, eclimit="1000", limit="1000",
|
|
time=str(round(time.time()))
|
|
)
|
|
|
|
|
|
@server.handler("message", "get", matcher=ModelMatcher("KFC"))
|
|
def message(ctx):
|
|
ctx.resp.append("message", expire="300", status="0")
|
|
|
|
|
|
@server.handler("facility", "get")
|
|
def facility_get(ctx):
|
|
facility = ctx.resp.append("facility", status="0")
|
|
location = facility.append("location")
|
|
location.append("id", Type.Str, "")
|
|
location.append("country", Type.Str, "UK")
|
|
location.append("region", Type.Str, "")
|
|
location.append("name", Type.Str, "Hello Flask")
|
|
location.append("type", Type.U8, 0)
|
|
location.append("countryname", Type.Str, "UK-c")
|
|
location.append("countryjname", Type.Str, "")
|
|
location.append("regionname", Type.Str, "UK-r")
|
|
location.append("regionjname", Type.Str, "")
|
|
location.append("customercode", Type.Str, "")
|
|
location.append("companycode", Type.Str, "")
|
|
location.append("latitude", Type.S32, 0)
|
|
location.append("longitude", Type.S32, 0)
|
|
location.append("accuracy", Type.U8, 0)
|
|
|
|
line = facility.append("line")
|
|
line.append("id", Type.Str, "")
|
|
line.append("class", Type.U8, 0)
|
|
|
|
portfw = facility.append("portfw")
|
|
portfw.append("globalip", Type.IPv4, (*map(int, ctx.request.remote_addr.split(".")),))
|
|
portfw.append("globalport", Type.U16, ctx.request.environ.get('REMOTE_PORT'))
|
|
portfw.append("privateport", Type.U16, ctx.request.environ.get('REMOTE_PORT'))
|
|
|
|
public = facility.append("public")
|
|
public.append("flag", Type.U8, 1)
|
|
public.append("name", Type.Str, "")
|
|
public.append("latitude", Type.S32, 0)
|
|
public.append("longitude", Type.S32, 0)
|
|
|
|
share = facility.append("share")
|
|
eacoin = share.append("eacoin")
|
|
eacoin.append("notchamount", Type.S32, 0)
|
|
eacoin.append("notchcount", Type.S32, 0)
|
|
eacoin.append("supplylimit", Type.S32, 100000)
|
|
url = share.append("url")
|
|
url.append("eapass", Type.Str, "www.ea-pass.konami.net")
|
|
url.append("arcadefan", Type.Str, "www.konami.jp/am")
|
|
url.append("konaminetdx", Type.Str, "http://am.573.jp")
|
|
url.append("konamiid", Type.Str, "http://id.konami.jp")
|
|
url.append("eagate", Type.Str, "http://eagate.573.jp")
|
|
|
|
|
|
@server.handler("pcbevent", "put")
|
|
def pcbevent(ctx):
|
|
ctx.resp.append("pcbevent", status="0")
|
|
|
|
|
|
server.route_service_to("cardmng", server.service_route("cardmng"))
|
|
server.route_service_to("package", server.service_route("package"))
|
|
|
|
server.route_service_to("message", "message/KFC", matcher=ModelMatcher("KFC"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
server.run("0.0.0.0", 5000, debug=True)
|