Speed up development with full-stack environments for every branch.

Learn More

A simple web server in python

1156 Runs 6216 Views 1222 Copies
Saved

Saved

sundip 66

sundip
published 4 years ago

    ## Creating a basic web server in python without 
    ## any external modules or dependencies
    
    import os
    import SimpleHTTPServer
    import SocketServer
    
    ## 'SimpleHTTPRequestHeader' is setup to serve up any 
    ## files located in the current directory
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    
    httpd = SocketServer.TCPServer(("localhost", 80), Handler)
    
    print "serving at port: ", 80
    httpd.serve_forever()
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).