ZeroNet allows you to publish static and dynamic websites on a distributed web platform.
In this tutorial we are going to build a P2P, decentralized, server-less chat site in less then 100 lines of code.
ZeroNet Debug mode¶
ZeroNet comes with a
--debug flag that will make site development easier.
To run ZeroNet in debug mode use:
python zeronet.py --debug
If you are using compiled/bundled version of ZeroNet:
- On Windows:
- On Linux:
- On Mac:
Debug mode features:¶
- Debug messages will appear in the console
- Auto reload of some source files (UiRequest, UiWebsocket, FileRequest) on modification to prevent restarting (Requires PyFilesystem on GNU/Linux)
http://127.0.0.1:43110/DebugTraceback and interactive Python console at the last error position (using the wonderful Werkzeug debugger - Requires Werkzeug)
http://127.0.0.1:43110/ConsoleSpawns an interactive Python console (Requires Werkzeug)
Disable HTTP Browser Caching¶
In addition to Debug Mode, disabling HTTP Caching in the browser is an essential part of ZeroNet site development. Modern web browsers attempt to cache web content whenever they can. As all ZeroNet sites run in an iframe, web browsers cannot detect when a ZeroNet site's content changes, and thus site changes are often not reflected if HTTP Caching is enabled.
To disable, open your browser's devtools, navigate to the devtools settings and check the option along the lines of 'Disable HTTP Cache (when toolbox is open)'. As the setting suggests, make sure to keep devtools open when testing new changes to your site!
Extra features (works only for sites that you own)¶
- Merged CSS files: All CSS files inside the site folder will be merged into one file called
all.css. You can choose to include only this file to your site. If you want to keep the other CSS files to make the development easier, you can add them to the ignore key of your
content.json. This way, they won't be published with your site. (eg: add to your
"ignore": "(js|css)/(?!all.(js|css))"this will ignore all CSS and JS files except
- Merged JS files: All JS files inside the site folder will be merged into one file called
all.js. If a CoffeeScript compiler is present (bundled for Windows) it will convert
- Order in which files are merged into all.css/all.js: Files inside subdirectories of the css/js folder comes first; Files in the css/js folder will be merged according to file name ordering (01_a.css, 02_a.css, etc)
ZeroNet has a growing community of developers who hang out in various spaces. If you would like to ask for help, advice or just want to hang out, feel free to connect in to the following services:
- #zeronet-dev:matrix.org on Matrix
- IRC at #zeronet on Freenode