Update app.py
Browse files
app.py
CHANGED
|
@@ -1,55 +1,47 @@
|
|
| 1 |
-
|
| 2 |
import sqlite3
|
| 3 |
import os
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
|
| 6 |
-
|
| 7 |
-
st.set_page_config(page_title="Hitech Telegram Search", page_icon="🔍")
|
| 8 |
|
| 9 |
-
|
| 10 |
-
st.markdown("### 72.6 Million Unique Records Database")
|
| 11 |
-
|
| 12 |
-
# --- DATABASE SETUP ---
|
| 13 |
REPO_ID = "Watchhrr/Telegram"
|
| 14 |
DB_FILE = "Telegram_part_1_DB.db"
|
| 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 |
-
st.info("Please enter a search term.")
|
| 53 |
-
|
| 54 |
-
st.divider()
|
| 55 |
-
st.caption("Powered by Midnight Syndicate | 72M Unique Records")
|
|
|
|
| 1 |
+
from fastapi import FastAPI, Query
|
| 2 |
import sqlite3
|
| 3 |
import os
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
|
| 6 |
+
app = FastAPI(title="Hitech OSINT API")
|
|
|
|
| 7 |
|
| 8 |
+
# --- CONFIG ---
|
|
|
|
|
|
|
|
|
|
| 9 |
REPO_ID = "Watchhrr/Telegram"
|
| 10 |
DB_FILE = "Telegram_part_1_DB.db"
|
| 11 |
|
| 12 |
+
# Database download on startup
|
| 13 |
+
DB_PATH = hf_hub_download(repo_id=REPO_ID, filename=DB_FILE, repo_type="dataset")
|
| 14 |
+
|
| 15 |
+
@app.get("/search")
|
| 16 |
+
def hitech_search(q: str = Query(None, description="Phone number or User ID")):
|
| 17 |
+
if not q:
|
| 18 |
+
return {"status": "error", "message": "Query parameter 'q' is missing. Use /search?q=YOUR_QUERY"}
|
| 19 |
+
|
| 20 |
+
# Cleaning input
|
| 21 |
+
clean_q = ''.join(filter(str.isdigit, str(q)))
|
| 22 |
+
|
| 23 |
+
conn = sqlite3.connect(DB_PATH)
|
| 24 |
+
conn.row_factory = sqlite3.Row # Dictionary format
|
| 25 |
+
cursor = conn.cursor()
|
| 26 |
+
|
| 27 |
+
# Optimized Query
|
| 28 |
+
sql = "SELECT * FROM users WHERE user_id = ? OR phone = ? LIMIT 50"
|
| 29 |
+
cursor.execute(sql, (q, clean_q))
|
| 30 |
+
|
| 31 |
+
results = [dict(row) for row in cursor.fetchall()]
|
| 32 |
+
conn.close()
|
| 33 |
+
|
| 34 |
+
if not results:
|
| 35 |
+
return {"status": "success", "count": 0, "data": [], "msg": "No records found."}
|
| 36 |
+
|
| 37 |
+
return {
|
| 38 |
+
"status": "success",
|
| 39 |
+
"total_results": len(results),
|
| 40 |
+
"data": results,
|
| 41 |
+
"provider": "Midnight Syndicate"
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
@app.get("/")
|
| 45 |
+
def home():
|
| 46 |
+
return {"status": "online", "endpoint": "/search?q={id_or_phone}"}
|
| 47 |
+
|
|
|
|
|
|
|
|
|
|
|
|