mkt-phone/web/app.py
2023-06-28 16:45:24 +07:00

53 lines
1.5 KiB
Python

from urllib import request
from flask import Flask, jsonify, render_template, url_for, request, redirect
import json
import datetime
from pymongo import MongoClient
CONNECTION_STRING = "mongodb://mongodb:Cc03Wz5XX3iI3uY3@mongo"
db_connection = MongoClient(CONNECTION_STRING)
db_base = db_connection["phone"]
coll_call = db_base["phone"]
coll_history = db_base["history"]
app = Flask(__name__)
internal = {}
external = {}
State = ""
findLimit = 1000
@app.route("/")
def root():
return "Ok"
IgnoreList = ['83919865589', '83912051046', '83912051045', '84950213944', '84951252791', '83919865589',
'84951183750', '89919237009', '89919241441', '89919863883', '89919505445', '89919398228', '89919500798']
@app.route("/web/call/")
def WebCall():
call = coll_call.find().sort('time', -1)
return render_template("WebCall.html", call=call)
@app.route("/web/call/status/<id>")
def WebCallStatus(id):
call = coll_call.find(
{'client': {'$nin': IgnoreList}, 'status': int(id)}).limit(findLimit).sort('time', -1)
return render_template("WebCall.html", call=call)
@app.route("/web/call/find/", methods=["GET"])
def WebCallFind():
try:
id = str(request.args.get("client"))
call = coll_call.find({"client": {"$regex": str(id)}}).limit(findLimit).sort('time', -1)
return(render_template("WebCall.html", call=call))
except Exception as e:
return(str(e))
if __name__ == "__main__":
app.debug = True
app.run(host="0.0.0.0", port=5001)