forked from tinode/chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,57 @@ | ||
from flask import Flask, jsonify | ||
from flask import Flask, jsonify, make_response | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route('/') | ||
def index(): | ||
return 'Sample REST authentication service. '+\ | ||
return 'Sample Tinode REST authentication service. '+\ | ||
'See <a href="https://github.com/tinode/chat/rest-auth/">https://github.com/tinode/chat/rest-auth/</a> for details.' | ||
|
||
@app.route('/add') | ||
@app.route('/add', methods=['POST']) | ||
def add(): | ||
return jsonify({"err":"unsupported"}) | ||
return jsonify({'err': 'unsupported'}) | ||
|
||
@app.route('/auth') | ||
@app.route('/auth', methods=['POST']) | ||
def auth(): | ||
if not request.json: | ||
return jsonify({'err': 'malformed'}) | ||
|
||
return "" | ||
|
||
@app.route('/checkunique') | ||
@app.route('/checkunique', methods=['POST']) | ||
def checkunique(): | ||
return jsonify({"err":"unsupported"}) | ||
return jsonify({'err': 'unsupported'}) | ||
|
||
@app.route('/del') | ||
@app.route('/del', methods=['POST']) | ||
def xdel(): | ||
return jsonify({"err":"unsupported"}) | ||
return jsonify({'err': 'unsupported'}) | ||
|
||
@app.route('/gen') | ||
@app.route('/gen', methods=['POST']) | ||
def gen(): | ||
return jsonify({"err":"unsupported"}) | ||
return jsonify({'err': 'unsupported'}) | ||
|
||
@app.route('/link') | ||
@app.route('/link', methods=['POST']) | ||
def link(): | ||
return "" | ||
if not request.json: | ||
return jsonify({'err': 'malformed'}) | ||
|
||
rec = request.json.get('rec', None) | ||
secret = request.json.get('secret', '') | ||
if not rec or not rec['uid'] or not secret: | ||
return jsonify({'err': 'malformed'}) | ||
|
||
@app.route('/upd') | ||
# TODO: save the link account <-> secret to database. | ||
|
||
# Success | ||
return jsonify({}) | ||
|
||
@app.route('/upd', methods=['POST']) | ||
def upd(): | ||
return jsonify({"err":"unsupported"}) | ||
return jsonify({'err': 'unsupported'}) | ||
|
||
@app.errorhandler(404) | ||
def not_found(error): | ||
return make_response(jsonify({'err': 'not found'}), 404) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |