|
6 | 6 | import sys |
7 | 7 | import json |
8 | 8 |
|
9 | | -app = Flask(__name__, template_folder='templates') |
10 | | -app.register_blueprint(api, url_prefix='/api') |
| 9 | +app = Flask(__name__, template_folder="templates") |
| 10 | +app.register_blueprint(api, url_prefix="/api") |
11 | 11 | socketio = SocketIO(app) |
12 | 12 |
|
13 | 13 |
|
14 | | -@app.route('/') |
| 14 | +@app.route("/") |
| 15 | +@app.route("/index.html") |
15 | 16 | def home(): |
| 17 | + """Render home page.""" |
16 | 18 | return render_template("index.html") |
17 | 19 |
|
18 | 20 |
|
19 | | -@app.route("/create_document", methods=['POST']) |
| 21 | +@app.route("/create_document", methods=["POST"]) |
20 | 22 | def create_document(): |
| 23 | + """Create a new document/code file.""" |
21 | 24 | doc_id = db.create_document() |
22 | 25 | return redirect(f"/{doc_id}") |
23 | 26 |
|
24 | 27 |
|
25 | | -@app.route('/<doc_id>') |
26 | | -@app.route('/editor/<doc_id>') |
| 28 | +@app.route("/<doc_id>") |
| 29 | +@app.route("/editor/<doc_id>") |
27 | 30 | def editor(doc_id): |
| 31 | + """Enter editor with document id. |
| 32 | +
|
| 33 | + :pre: |
| 34 | + doc_id: str, 5 char - in database |
| 35 | + """ |
28 | 36 | content = db.get_document(doc_id) |
29 | | - content['content'] = json.loads(content['content']) |
| 37 | + content["content"] = json.loads(content["content"]) |
30 | 38 | if doc_id is not None: |
31 | | - return render_template('editor.html', document=content) |
| 39 | + return render_template("editor.html", document=content) |
32 | 40 | return abort(404) |
33 | 41 |
|
34 | 42 |
|
35 | | -@app.route('/tos') |
36 | | -@app.route('/tac') |
| 43 | +@app.route("/tos") |
| 44 | +@app.route("/tac") |
| 45 | +@app.route("/termsofservice") |
| 46 | +@app.route("/terms-of-service") |
37 | 47 | def tos(): |
38 | | - return render_template('legal/tos.html') |
| 48 | + """Render terms of service.""" |
| 49 | + return render_template("legal/tos.html") |
39 | 50 |
|
40 | 51 |
|
41 | | -@app.route('/privacy') |
| 52 | +@app.route("/privacy") |
| 53 | +@app.route("/privacypolicy") |
| 54 | +@app.route("/privacy-policy") |
42 | 55 | def privacy(): |
43 | | - return render_template('legal/privacy.html') |
| 56 | + """Render privacy policy.""" |
| 57 | + return render_template("legal/privacy.html") |
44 | 58 |
|
45 | 59 |
|
46 | | -@app.route('/licence') |
| 60 | +@app.route("/licence") |
47 | 61 | def licence(): |
48 | | - return render_template('legal/licence.html') |
| 62 | + """Render Project licence.""" |
| 63 | + return render_template("legal/licence.html") |
49 | 64 |
|
50 | 65 |
|
51 | 66 | @socketio.on("join") |
52 | 67 | def on_join(data): |
53 | | - room = data['room'] |
| 68 | + room = data["room"] |
54 | 69 | join_room(room) |
55 | 70 |
|
56 | 71 |
|
57 | | -@socketio.on('update text') |
| 72 | +@socketio.on("update text") |
58 | 73 | def update_text(data): |
59 | | - emit('text updated', data, room=data['room'], include_self=False) |
| 74 | + emit("text updated", data, room=data["room"], include_self=False) |
60 | 75 |
|
61 | 76 |
|
62 | | -@socketio.on('save') |
| 77 | +@socketio.on("save") |
63 | 78 | def update_text(data): |
64 | | - db.update_document(data['room'], json.dumps(data['requests'][0]['data'])) |
| 79 | + db.update_document(data["room"], json.dumps(data["requests"][0]["data"])) |
65 | 80 |
|
66 | 81 |
|
67 | 82 | @app.errorhandler(404) |
68 | 83 | def page_not_found(e): |
69 | | - return render_template('404.html'), 404 |
| 84 | + return render_template("404.html"), 404 |
70 | 85 |
|
71 | 86 |
|
72 | | -if __name__ == '__main__': |
| 87 | +if __name__ == "__main__": |
73 | 88 | socketio.run(app, *sys.argv[1:], debug=DEBUG) |
0 commit comments