-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivate.py
More file actions
executable file
·60 lines (49 loc) · 1.77 KB
/
activate.py
File metadata and controls
executable file
·60 lines (49 loc) · 1.77 KB
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
#!/usr/bin/env python3
import asyncio
from aiohttp import web, ClientSession
import urllib.parse
import sys
url = "https://identity.vertigisstudio.com/authorize?client_id=pTmBlZldlUaNrhFn&redirect_uri=http%3A%2F%2Flocalhost%3A7780%2Fa5510196-002b-4e2e-ba4e-8fdb91ee5287%2Fonline-activate&response_mode=form_post&activate=no_grant"
async def handle_post(request):
status = 404
try:
data = await request.post()
id = data.get("id", "")
idUrl = data.get("idUrl", "")
if id and idUrl:
full_url = f"{idUrl}?id={id}"
async with ClientSession() as session:
async with session.get(full_url) as resp:
result = await resp.json()
accountId = result.get("accountId")
if accountId and isinstance(accountId, str):
print("VertiGIS Account ID:", accountId)
asyncio.get_event_loop().call_later(0.1, shutdown)
status=200
except:
pass
return web.Response(status=status, content_type="text/plain")
def shutdown():
loop = asyncio.get_event_loop()
for task in asyncio.all_tasks(loop):
task.cancel()
async def main():
app = web.Application()
app.router.add_post('/{tail:.*}', handle_post)
runner = web.AppRunner(app)
await runner.setup()
site = web.TCPSite(runner, None, 7780)
await site.start()
print("Listening: http://localhost:7780/")
print("Please Visit: " + url)
sys.stdout.flush()
try:
while True:
await asyncio.sleep(3600)
except asyncio.CancelledError:
await runner.cleanup()
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
pass