Python 3 Tools
This guide demonstrates useful Python 3 commands for web development and debugging.
Setting up a Simple Web Server
To start a basic web server in your current directory, use the following commands:
# Python 3
python -m http.server 8000
This will start the server on port 8000. Access it via http://127.0.0.1:8000
Debugging with SMTP Server
For debugging email-related issues, a simple SMTP server can be helpful. This example discards messages but prints them to your console:
# SMTP-Server for debugging, messages will be discarded, and printed on stdout.
python -m smtpd -n -c DebuggingServer localhost:1025
JSON Handling
Use the json.tool
module for pretty-printing JSON data:
# Pretty print a json
python -m json.tool foo.json
Remember to replace foo.json
with your JSON file.