2024-06-11 03:25:52 +02:00
|
|
|
#!/usr/bin/env python3
|
2024-06-11 03:09:22 +02:00
|
|
|
from flask import Flask, request, abort
|
|
|
|
from voipms.api import Client
|
|
|
|
import did, sms
|
|
|
|
import json
|
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
with open("config.json",'r') as conf_file:
|
|
|
|
conf = json.load(conf_file)
|
|
|
|
client = Client(conf["username"],conf["password"])
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/", methods=['GET'])
|
2024-06-11 03:35:48 +02:00
|
|
|
def default():
|
|
|
|
return '<a href="http://git.community.i2p/anons-voip/voipsms">Check out the project</a>'
|
2024-06-11 03:09:22 +02:00
|
|
|
|
|
|
|
@app.route("/numbers", methods=['GET'])
|
|
|
|
def get_numbers():
|
|
|
|
return did.get_numbers(client)
|
|
|
|
|
|
|
|
@app.route("/sms",methods=['GET', 'POST'])
|
|
|
|
def get_sms():
|
|
|
|
did = request.args.get('did')
|
|
|
|
return sms.get_sms(client, did)
|
|
|
|
|
|
|
|
|
|
|
|
@app.route("/enablesms",methods=['GET', 'POST'])
|
|
|
|
def set_sms():
|
|
|
|
abort(403)
|
|
|
|
did = request.args.get('did')
|
|
|
|
return sms.get_sms(client, did)
|
2024-06-11 03:25:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
from waitress import serve
|
|
|
|
serve(app, host="0.0.0.0", port=8080)
|