60 lines
1.6 KiB
Python
60 lines
1.6 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 = ""
|
|
|
|
|
|
@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/test/")
|
|
def GetTest():
|
|
call = coll_call.find({'client': {'$nin': IgnoreList}}).sort('time', -1)
|
|
return render_template("TestCall.html", call=call)
|
|
|
|
|
|
@app.route("/web/call/test/<id>")
|
|
def GetTestId(id):
|
|
call = coll_call.find(
|
|
{'client': {'$nin': IgnoreList}, 'status': int(id)}).sort('time', -1)
|
|
return render_template("TestCall.html", call=call)
|
|
|
|
|
|
@app.route("/web/call/status/<id>")
|
|
def WebCallStatus(id):
|
|
call = coll_call.find({"status": int(id)}).sort('time', -1)
|
|
call = coll_call.find(
|
|
{'client': {'$nin': IgnoreList}, 'status': int(id)}).sort('time', -1)
|
|
return render_template("WebCall.html", call=call)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.debug = True
|
|
app.run(host="0.0.0.0", port=5001)
|