-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_server.py
More file actions
35 lines (25 loc) · 831 Bytes
/
Copy pathverify_server.py
File metadata and controls
35 lines (25 loc) · 831 Bytes
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
"""
AAP verification server.
Handles impression verification callbacks from AI agents / clients.
Run:
pip install fastapi uvicorn
python verify_server.py
"""
import os
from fastapi import FastAPI, Query
from aap import AAPProvider
app = FastAPI(title="AAP Verification Server")
provider = AAPProvider.from_json(
os.path.join(os.path.dirname(__file__), "example_ads.json"),
)
@app.get("/verify")
def verify(token: str = Query(..., description="Impression token from _aap field")):
"""Verify that an ad impression was delivered."""
return provider.verify_impression(token)
@app.get("/stats")
def stats():
"""View impression stats (demo only — protect this in production)."""
return provider.stats()
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=5100)