PIC-a-so-CAT (picaso-cat or pick-a-socka) is an in-browser drawing app. It allows you to connect to a server and start drawing, storing your creations in a friendly text format.
Current features:
- Server sending HTTP responses
- a simple Flask server returns HTML responses on
localhost:5000
- Server with a simple stream
- the Flask server is streaming a list of proper names
- if you want to generate words on click, go to
localhost:5000/names
- if you want to generate a stream of words, go to
localhost:5000/generate
(1 word per second) - the stream is stored in a text file as a write-only log, you can download it at
localhost:5000/static/names_log
- Frontend sending clicks to the server
- your vanilla JavaScript frontend is sending clicks from a canvas element to the server
- the clicks are stored in a text file as a write-only log, you can download it at
localhost:5000/static/clicks_log
- you can see all the clicks on
localhost:5000/clicks
- and add some more!
- Connecting the dots
- your vanilla JavaScript frontend is drawing lines based on your mouse movement
- the lines are stored in a text file as a write-only log, you can download it at
localhost:5000/static/drawing_log
- you can see the drawing on
localhost:5000/draw
- and add some more lines!
- Drawing party
- anyone can connect to the server and start drawing on a shared canvas, with a randomly assigned color
- all the drawings are stored in the write-only log
Planned features:
- Customizations
- instead of preassigned colors, you will be able to draw with any color you pick
- you will be able to download the drawing as an image
- if you manage to color every pixel on the canvas, the server will respond with a random cat picture
Requirements: Python 3.6 backend, ES6/ES7 frontend, communication using websockets/REST API
-
Set up a Python virtual environment and run it
-
Install
requirements.txt
in your environment
-
Set the Flask environment variable:
export FLASK_APP=server/server.py
-
Run:
flask run
and go tolocalhost:5000
-
If you want live reloading, start the server with
python -m flask run
instead
-
Flask-SocketIO docs - https://flask-socketio.readthedocs.io/en/latest/
-
Flask-SocketIO tutorial (a bit outdated) - https://blog.miguelgrinberg.com/post/easy-websockets-with-flask-and-gevent
-
On using
gevent.sleep()
- https://stackoverflow.com/questions/30901998/threading-true-with-flask-socketio -
On using
DOMContentLoaded
- https://stackoverflow.com/questions/799981/document-ready-equivalent-without-jquery
- Favicon source