1

I am new to Python so i wanted to ask you for help.

In old versions of Python to create a server which would not store any logs and its standard output was redirected to dev/null to avoid saving information, we executed the following instruction:

nohup python -m SimpleHTTPServer 80 > /dev/null 2>&1 &

> /dev/null: Indicates that standard output is directed to /dev/null

2>&1: It indicates that all the errors that occur will not be stored in the log since they will be redirected to the standard output which we have redirected to /dev/null.

&: Indicates that this task will run in the background.

However, I don't know how to do it in the newer versions of Python, can you help me?

Tks guys.

Axisnix
  • 2,822
  • 5
  • 19
  • 41
Antuanct
  • 23
  • 7
  • The standard output / error redirection has nothing to do with Python - i.e., your command line would be identical to the example you've given regardless of the Python version –  Oct 01 '21 at 17:17
  • So the command would be: nohup python -m http.server 80 > /dev/null 2>&1 & Right? – Antuanct Oct 01 '21 at 17:41

1 Answers1

0

The SimpleHTTPServer module has been merged into http.server in Python >= 3.0. Try this one:

python -m http.server
Gabio
  • 9,126
  • 3
  • 12
  • 32
  • Thanks for your answer, but what about the standard outputs? How can I modify them? – Antuanct Oct 01 '21 at 17:40
  • output redirection and ruuning in background are OS commands, not related to python. You can add `nohup` and `> /dev/null 2>&1 &` here as well. – Gabio Oct 01 '21 at 17:53