75 lines
2.1 KiB
Python
75 lines
2.1 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)
|
|
|
|
|
|
@app.route("/web/call/delete/<id>")
|
|
def WebCallDelete(id):
|
|
return render_template("DeleteCall.html", id=id)
|
|
|
|
|
|
@app.route("/web/call/delete/confirm", methods=['POST'])
|
|
def WebCallDeleteConfirm():
|
|
phone = request.form.get("id")
|
|
reason = request.form.get('reason')
|
|
res = phone + " - " + reason
|
|
coll_call.update_one({'$and': [{'client': phone}, {'status': 1}]}, {
|
|
'$set': {'status': 9, 'reason': reason}})
|
|
return redirect("http://192.168.0.20:5001/web/call/status/1")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
app.debug = True
|
|
app.run(host="0.0.0.0", port=5002)
|