added basic flask server
This commit is contained in:
parent
8d73e7e779
commit
5fc948a617
1 changed files with 30 additions and 0 deletions
30
app/server.py
Normal file
30
app/server.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
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'])
|
||||
def hello_world():
|
||||
return "<p>Hello, World!</p>"
|
||||
|
||||
@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)
|
Loading…
Reference in a new issue