Python Forum
[SOLVED] Tiny web server as standalone executable?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] Tiny web server as standalone executable?
#1
Question 
Hello,

I need a basic, standalone web server with support for directory listing.

Windows' antivirus blocks Mongoose ("Trojan Win32 Wacatac.B!ml"), and neither Ritlabs Tinyweb server, Rebex Tiny Web Server, nor micro_httpd/mini_httpd provide the same features.

So I tried PyInstaller to create a standalone binary… but it fails:

www.py:
#ipconfig #how to display computer's IP address so user knows?
python -m http.server 8080

pip install -U pyinstaller

pyinstaller www.py
Syntax error in c:\temp\www.py
  File "c:\temp\www.py", line 2
     python -m http.server 8080
               ^^^^
 SyntaxError: invalid syntax
What's the right way to get a working binary?

Thank you.

--
Edit: An infinite loop is the way to go:

from http.server import HTTPServer, SimpleHTTPRequestHandler

#to listen on 192.168
addr = ("0.0.0.0", 8080)
print("Listening on " + str(addr))

httpd = HTTPServer(addr, SimpleHTTPRequestHandler)
httpd.serve_forever()

#netstat -ao | grep ^.LISTENING"
Note: PyInstaller doesn't create a single binary, standalone application: To run, the EXE requires a sub-directory (_internal) with several files:
  • base_library.zip
  • libcrypto-3.dll
  • libssl-3.dll
  • python312.dll
  • select.pyd
  • unicodedata.pyd
  • VCRUNTIME140.dll
  • _bz2.pyd
  • _decimal.pyd
  • _hashlib.pyd
  • _lzma.pyd
  • _socket.pyd
  • _ssl.pyd
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to take the tar backup files form remote server to local server sivareddy 0 1,917 Jul-14-2021, 01:32 PM
Last Post: sivareddy
  Run an app in a standalone terminal and wait until it's closed glestwid 2 2,536 Aug-30-2020, 08:14 AM
Last Post: glestwid
Lightbulb Standalone application samuelbachorik 8 3,566 Aug-02-2020, 01:57 PM
Last Post: samuelbachorik
  Python 3.4: the only release to create .EXE standalone without .dll samsonite 7 5,824 Feb-28-2019, 09:20 AM
Last Post: samsonite
  Launching executable over rest server api InsatiableBuns 0 1,997 Oct-25-2018, 12:22 PM
Last Post: InsatiableBuns
  Standalone interpreter? stf92 2 2,828 Mar-11-2018, 12:33 AM
Last Post: stf92
  Correct way to import from a standalone module in a different location chowder 3 18,401 Dec-16-2017, 07:44 PM
Last Post: Larz60+
  display .jpg in tiny led with PIL tony1812 0 2,236 Sep-04-2017, 05:00 PM
Last Post: tony1812

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020