Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7960493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:46:11+00:00 2026-06-04T04:46:11+00:00

How do I only display simplehttpwebsite_content.html when I visit localhost:8080 ? So that I

  • 0

How do I only display simplehttpwebsite_content.html when I visit localhost:8080? So that I can’t see my filetree, only the webpage. All these files are in the same directory btw.

simplehttpwebsite.py

#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer

Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
server = SocketServer.TCPServer(('0.0.0.0', 8080), Handler)

server.serve_forever()

simplehttpwebsite_content.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="simplehttpwebsite_style.css">
  </head>

  <body>
    This is my first web page
  </body>
</html>

simplehttpwebsite_style.css

body{background-color:blue;}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:46:12+00:00Added an answer on June 4, 2026 at 4:46 am

    You can extend SimpleHTTPServer.SimpleHTTPRequestHandler and override the do_GET method to replace self.path with simplehttpwebpage_content.html if / is requested.

    #!/usr/bin/env python
    import SimpleHTTPServer
    import SocketServer
    
    class MyRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
        def do_GET(self):
            if self.path == '/':
                self.path = '/simplehttpwebpage_content.html'
            return SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
    
    Handler = MyRequestHandler
    server = SocketServer.TCPServer(('0.0.0.0', 8080), Handler)
    
    server.serve_forever()
    

    Since SimpleHTTPServer.SimpleHTTPRequestHandler extends BaseHTTPServer.BaseHTTPRequestHandler, you can read their documentations to figure what methods and instance variables are available and how you can manipulate them.

    You can find the path variable mentioned in the documentation of BaseHTTPServer.BaseHTTPRequestHandler. You can find the do_GET() method mentioned in the documentation of SimpleHTTPServer.SimpleHTTPRequestHandler.

    Here is some output from my shell to show what happens when I run this program and then I try to access http://localhost:8080/

    susam@swift:~/so$ ls
    simplehttpwebpage_content.html  simplehttpwebpage.py  simplehttpwebsite_style.css
    susam@swift:~/so$ python simplehttpwebpage.py
    swift - - [19/Apr/2012 09:10:23] "GET / HTTP/1.1" 200 -
    swift - - [19/Apr/2012 09:10:26] "GET /simplehttpwebsite_style.css HTTP/1.1" 200 -
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way that I can make codeigniter only display « Older Articles
Is there a tag in HTML that will only display its content if JavaScript
is there any special input type in HTML that is designed to only display
How can I only display a UIButton if the front camera is present on
The following code can only display the last number: for (i=0; i<3; i++) textbox.text({0},i);
I am attempting to create a table that will only display one row at
How can I display only selected headers in DataGridView control? For example I have
I want to have display-only fields to render data that's never going to be
I am building small app that will only display products in various categories. And
I have this query that should display all posts related to a specific tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.