Bruhletme commited on
Commit
08e1a67
·
verified ·
1 Parent(s): efa2dee

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -0
  2. app.py +36 -0
  3. requirements.txt +2 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+ RUN pip install --no-cache-dir -r requirements.txt
7
+
8
+ COPY . .
9
+
10
+ ENV PORT=7860
11
+ EXPOSE 7860
12
+
13
+ CMD ["python", "app.py"]
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3, re, os
2
+ from flask import Flask, request, jsonify
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ app = Flask(__name__)
6
+
7
+ DB_PATH = hf_hub_download(
8
+ repo_id="Bruhletme/Paytm",
9
+ filename="paytm.db",
10
+ repo_type="dataset",
11
+ token=os.environ.get("HF_TOKEN")
12
+ )
13
+
14
+ def query_db(q, a=()):
15
+ conn = sqlite3.connect(DB_PATH)
16
+ conn.row_factory = sqlite3.Row
17
+ cur = conn.cursor()
18
+ cur.execute(q, a)
19
+ r = cur.fetchall()
20
+ conn.close()
21
+ return [dict(x) for x in r]
22
+
23
+ @app.route("/num")
24
+ def num():
25
+ num = (request.args.get("info") or "").strip()
26
+ num = re.sub(r"\D","",num)[-10:]
27
+ if len(num)!=10:
28
+ return jsonify({"error":"invalid"}),400
29
+ d = query_db("SELECT * FROM users WHERE mobile=? LIMIT 1",(num,))
30
+ return jsonify({"found":bool(d),"data":d[0] if d else None})
31
+
32
+ @app.route("/")
33
+ def home():
34
+ return {"status":"ok"}
35
+
36
+ app.run(host="0.0.0.0", port=7860)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flask
2
+ huggingface_hub