-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
39 lines (33 loc) · 956 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from flask import Flask, render_template
from webargs.flaskparser import use_args
from flask_socketio import join_room
from flask_socketio import SocketIO
from webargs import fields
from flask import request
app = Flask(__name__)
app.config["SECRET_KEY"] = "Lorem ipsum dor sit amet"
socketio = SocketIO(app)
args = {
"signature": fields.Str(required=True),
"address": fields.Str(required=True)
}
@app.route("/")
def index():
return render_template("index.html")
@app.route("/app.json")
def app_json():
return {
"name": "Callback Test",
"icon": "https://callback.codepillow.io/static/codepillow.png"
}
@app.route("/call/<string:session>", methods=["POST"])
@use_args(args, location="json")
def call(args, session):
socketio.emit(session, args, to=session)
return {
"status": "success"
}
@socketio.on("callback")
def callback(session, *args):
join_room(session, request.sid)
return True