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 8179699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:03:32+00:00 2026-06-07T00:03:32+00:00

I created a python server on port 8000 using python -m SimpleHTTPServer . When

  • 0

I created a python server on port 8000 using python -m SimpleHTTPServer.

When I visit this url from my web browser it shows the below content

enter image description here

Now, I want to get the above content using python. So, for that what I did is

>>> import socket
>>> s = socket.socket(
...     socket.AF_INET, socket.SOCK_STREAM)
>>> s.connect(("localhost", 8000))
>>> s.recv(1024)

But after s.recv(1024) nothing happens it just wait there and prints nothing.

So, my question is how to get above directory content output using python. Also can someone suggest me a tutorial on socket programming with python. I didn’t liked the official tutorial that much.

I also observed a strange thing when I try to receive contents using python and nothing happens at that time I cannot access localhost:8000 from my web browser but as soon as I kill my python program I can access it.

  • 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-07T00:03:33+00:00Added an answer on June 7, 2026 at 12:03 am

    Arguably the simplest way to get content over http in python is to use the urllib2 module. For example:

    from urllib2 import urlopen
    f = urlopen('http://localhost:8000')
    for line in f:
        print line
    

    This will print out the file hosted by SimpleHTTPServer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a little web spider in Python which I'm using to collect URLs.
I have created a python web app with this directory structure: # cd /usr/local/www/myapp
I've created a Python web app using CherryPy, and have deployed in on my
I'm trying to write a python web server using the socket library. I've been
I have written a Python TCP/IP server for internal use, using win32serviceutil/py2exe to create
I created a python .py with some sort methods. I'm using numpy so that
Is there a way to redirect from one server port to another? I have
I'm trying to create a python server that will serve calls from outer source
I made a SMTP server using smtpd module in python. I have been able
i am programing a client/server software in Python using sockets. I have a question,

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.