

- BASEHTTPSERVER PYTHON 3 INSTALL HOW TO
- BASEHTTPSERVER PYTHON 3 INSTALL FULL
- BASEHTTPSERVER PYTHON 3 INSTALL SOFTWARE
- BASEHTTPSERVER PYTHON 3 INSTALL FREE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
BASEHTTPSERVER PYTHON 3 INSTALL SOFTWARE
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # all copies or substantial portions of the Software. # The above copyright notice and this permission notice shall be included in # furnished to do so, subject to the following conditions: # copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
BASEHTTPSERVER PYTHON 3 INSTALL FREE
# Permission is hereby granted, free of charge, to any person obtaining a copy Webserver-foobar-8080.err webserver-foobar-8080.log webserver-foobar-8080.pid $ webserver -host foobar -port 8080 -level warning -no-dirlist -rootdir ~/www -daemonize ~/www/logs (stderr) and pid (process id) files for the daemon process. That directory will contain the log (stdout), err To daemonize a process, specify the -d or -daemonize option with a $ webserver -host foobar -port 8080 -level warning -no-dirlist -rootdir ~/www Server for host foobar on port 8080 with no directory listingĬapability and very little output serving files from ~/www:
BASEHTTPSERVER PYTHON 3 INSTALL HOW TO
The example below shows how to use a number of the switches to run a The URL like this: This will not work if the Index.html or index.htm directory, type three trailing backslashes in

If you want to see a directory listing of a directory that contains a Try entering to see some server information.īy default the server allows you to see directory listings if there is Now go to your browser and enter on the command If you do not specify a root directory, it will use the directory that See the on-line help for more information (-h, You can change both the host name and the port using the -hostĪnd -port options. This will start the web server listening on your localhost on portĨ080. So you start the server and point to the ~/www root directory: Something like this will do nicely:Īt this point you have a basic web infrastructure with a single file You then add an HTML file: ~/It can be very Somewhere like you home directory: ~/www. You start by creating a simple index.html file in web directory Use it as a starting point to create aĬustom web server for handling specific requests but don't try to use Simple web server that demonstrates how browser/server interactions
BASEHTTPSERVER PYTHON 3 INSTALL FULL
The source code for webserver.py is presented in full below for interactive reference but it probably makes more sense to download it so that you can search through it in your favorite editor. This is simply to demonstrate that it can be done. Yet another interesting feature is that the POST request handler redirects to a custom page with a back button. For example you add the content headers for handling different file extensions which in the current implementation are in the do_GET() handler method.Īnother interesting feature is setting the content type based on the file extension. You could add any arbitrary class arguments this way. The first is the use of the class factory make_request_handler_class to allow the request object to have access to the command line options, specifically the root directory for accessing files to display for GET requests. There are a number of interesting features of this example. It uses argparse to manage the command lines arguments. This implementation uses the BaseHTTPServer and cgi packages for creating the server and processing browser requests. If you want to go further, you try creating your own HTML or javascript files. This shows, in a crude way, how you can enter custom URLs.Īt this point you have verified that the simple web server is working. Now try entering “ ” and you will see internal server information. In both case, you inspect the source code to see how the form data was captured and processed from the browser request. If you enter data in the “Form Using POST” fieldset, the argument values will in the webserver output log and on a new page. If you enter data in the “Form Using GET” fieldset, the argument values will appear in the webserver output log. If server is running properly you will see something like this: Now that the server is running you can access the webserver.html page by entering the following URL: (you can also use 0.0.0.0 if that is easier to type). Version 1.2 or later.ĭisable directory listings.

Logging level: noset, debug, info, warning, error, critical. Daemonize this process, store the 3 run files (.log.
