Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 60306b9

Browse files
author
bhasher
committed
Merge branch 'master' of https://github.com/allEyezOnCode/CodeWe
2 parents 0d9f507 + f353761 commit 60306b9

File tree

3 files changed

+47
-24
lines changed

3 files changed

+47
-24
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ git clone https://github.com/allEyezOnCode/CodeWe.git
1212
cd CodeWe
1313
pip install -r requirements.txt
1414
```
15+
### Build with docker (instable)
16+
change Host to 0.0.0.0 and run the following :
17+
18+
`sudo docker-compose up`
19+
20+
`sudo docker-compose up -d --no-deps --build`
21+
22+
Help wanted to configure it correctly
1523

1624
## Usage
1725
To run the server, open a terminal in the folder and run :

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ services:
99
ports:
1010
- '5000:5000'
1111
db:
12-
image: mysql:5.7
12+
image: mysql:8.0.20
1313
ports:
1414
- "32000:3306"
1515
command: --init-file /create_db.sql
1616
volumes:
1717
- ./db/sql_files/create_db.sql:/create_db.sql
1818
environment:
19-
MYSQL_ROOT_PASSWORD: set_password_here
19+
MYSQL_ROOT_PASSWORD: root

src/main.py

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,68 +6,83 @@
66
import sys
77
import json
88

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")
1111
socketio = SocketIO(app)
1212

1313

14-
@app.route('/')
14+
@app.route("/")
15+
@app.route("/index.html")
1516
def home():
17+
"""Render home page."""
1618
return render_template("index.html")
1719

1820

19-
@app.route("/create_document", methods=['POST'])
21+
@app.route("/create_document", methods=["POST"])
2022
def create_document():
23+
"""Create a new document/code file."""
2124
doc_id = db.create_document()
2225
return redirect(f"/{doc_id}")
2326

2427

25-
@app.route('/<doc_id>')
26-
@app.route('/editor/<doc_id>')
28+
@app.route("/<doc_id>")
29+
@app.route("/editor/<doc_id>")
2730
def editor(doc_id):
31+
"""Enter editor with document id.
32+
33+
:pre:
34+
doc_id: str, 5 char - in database
35+
"""
2836
content = db.get_document(doc_id)
29-
content['content'] = json.loads(content['content'])
37+
content["content"] = json.loads(content["content"])
3038
if doc_id is not None:
31-
return render_template('editor.html', document=content)
39+
return render_template("editor.html", document=content)
3240
return abort(404)
3341

3442

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")
3747
def tos():
38-
return render_template('legal/tos.html')
48+
"""Render terms of service."""
49+
return render_template("legal/tos.html")
3950

4051

41-
@app.route('/privacy')
52+
@app.route("/privacy")
53+
@app.route("/privacypolicy")
54+
@app.route("/privacy-policy")
4255
def privacy():
43-
return render_template('legal/privacy.html')
56+
"""Render privacy policy."""
57+
return render_template("legal/privacy.html")
4458

4559

46-
@app.route('/licence')
60+
@app.route("/licence")
4761
def licence():
48-
return render_template('legal/licence.html')
62+
"""Render Project licence."""
63+
return render_template("legal/licence.html")
4964

5065

5166
@socketio.on("join")
5267
def on_join(data):
53-
room = data['room']
68+
room = data["room"]
5469
join_room(room)
5570

5671

57-
@socketio.on('update text')
72+
@socketio.on("update text")
5873
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)
6075

6176

62-
@socketio.on('save')
77+
@socketio.on("save")
6378
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"]))
6580

6681

6782
@app.errorhandler(404)
6883
def page_not_found(e):
69-
return render_template('404.html'), 404
84+
return render_template("404.html"), 404
7085

7186

72-
if __name__ == '__main__':
87+
if __name__ == "__main__":
7388
socketio.run(app, *sys.argv[1:], debug=DEBUG)

0 commit comments

Comments
 (0)