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

  • Home
  • SEARCH
  • 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 836395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:58:27+00:00 2026-05-15T04:58:27+00:00

I try to implement simple server on python based on HTTPServer. How can i

  • 0

I try to implement simple server on python based on HTTPServer.
How can i extract information about site domain served in current request?
I mean it can serv several domains such as site1.com and site2.com for example, how can i get it in this code:

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer

class MyHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        print "get"
        self.send_response(200)
        self.send_header("Content-type", "text/html")
        self.end_headers()
        #how can i get here host name of serving site?
        #site1.com or site2.com ?
        domain = ???
        self.wfile.write('<html>Welcome on www.%s.com</html>' % (domain))



if __name__ == "__main__":
    try:
        server = HTTPServer(("", 8070), MyHandler)
        print "started httpserver..."
        server.serve_forever()
    except KeyboardInterrupt:
        print "^C received, shutting down server"
        server.socket.close()
  • 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-05-15T04:58:28+00:00Added an answer on May 15, 2026 at 4:58 am

    I guess you should be able to read the Host header.
    The headers can be accessed from BaseHTTPRequestHandler.headers

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

Sidebar

Ask A Question

Stats

  • Questions 535k
  • Answers 535k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes for iOS aps there is typically only one UIWindow..… May 17, 2026 at 1:04 am
  • Editorial Team
    Editorial Team added an answer For the files, if you want access control on your… May 17, 2026 at 1:04 am
  • Editorial Team
    Editorial Team added an answer No. PS: someone can say again that short answers are… May 17, 2026 at 1:04 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I've implement simple udp server on my Android device.(sdk 1.5) it works fine when
If I try to implement this simple-as-possible example: Update Content with AJAXRefreshRequest it does
I was hoping to implement a simple XMPP server in Java. What I need
I'm looking to implement a simple cache without doing too much work (naturally). It
I have created a simple chat server that is driven by client polling. Clients
I'm trying to implement a simple drag/drop of images between panels using jQuery. While
I'm trying to implement a simple activity that will let user to insert a
I am working on a Spring web application and need to implement a simple
I am trying out GWT in this 'configuration': 1) I have written a server
I am tasked to develop a very simple web layer for a very complex

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.