FAQ
I want to update the configuration file for python server ,but i am
not able to locate the python configuration file.
Please guide me in this respect.

I am using a python web server
This is the code for it

-------------------------------------------------------
import string,cgi,time
from os import curdir, sep
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
#import pri
class MyHandler(BaseHTTPRequestHandler):
def do_GET(self):
try:
if self.path.endswith(".html"):
f = open(curdir + sep + self.path) #self.path has /
test.html
#note that this potentially makes every file on your computer readable
by the internet
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(f.read())
f.close()
return
if self.path.endswith(".esp"): #our dynamic content
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write("hey, today is the" +
str(time.localtime()[7]))
self.wfile.write(" day in the year " +
str(time.localtime()[0]))
return

return

except IOError:
self.send_error(404,'File Not Found: %s' % self.path)

def do_POST(self):
global rootnode
try:
ctype, pdict =
cgi.parse_header(self.headers.getheader('content-type'))
if ctype == 'multipart/form-data':
query=cgi.parse_multipart(self.rfile, pdict)
self.send_response(301)

self.end_headers()
upfilecontent = query.get('upfile')
print "filecontent", upfilecontent[0]
self.wfile.write("<HTML>POST OK.<BR><BR>");
self.wfile.write(upfilecontent[0]);

except :
pass
def main():
try:
server = HTTPServer(('', 80), MyHandler)
print 'started httpserver...'
server.serve_forever()
except KeyboardInterrupt:
print '^C received, shutting down server'
server.socket.close()
if __name__ == '__main__':
main()
----------------------------------------

sample Configuration file for Apache server

<VirtualHost *>
ServerAdmin webmaster at localhost
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default
start page
# in /apache2-default/, but still have / go to the
right place
#RedirectMatch ^/$ /apache2-default/
</Directory>

I want to update the configuration file for python server ,but i am
not able to locate the python configuration file.
Please guide me in this respect.

Search Discussions

  • David Zaslavsky at Jun 15, 2010 at 12:53 am

    On Monday 14 June 2010 6:19:33 am shanti bhushan wrote:
    I want to update the configuration file for python server ,but i am
    not able to locate the python configuration file.
    What configuration file? I don't see anything in your code that reads a
    configuration file.

    :) David
  • Shanti bhushan at Jun 15, 2010 at 3:29 am

    On Jun 15, 5:53?am, David Zaslavsky wrote:
    On Monday 14 June 2010 6:19:33 am shanti bhushan wrote:> I want to update the configuration file for python server ,but i am
    not able to locate the python configuration file.
    What configuration file? I don't see anything in your code that reads a
    configuration file.

    :) David
    like this code
    <VirtualHost *>
    ServerAdmin webmaster at localhost
    DocumentRoot /var/www/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    # This directive allows us to have apache2's default
    start page
    # in /apache2-default/, but still have / go to the
    right place
    #RedirectMatch ^/$ /apache2-default/
    </Directory>
    for apache we can configure the apache server.
    do we have some configuration file for python server??
    if yes please tell me which configuration file should be used
  • David Zaslavsky at Jun 15, 2010 at 9:30 pm

    On Monday 14 June 2010 11:29:35 pm shanti bhushan wrote:
    do we have some configuration file for python server??
    No.

    As people have explained in reply to your other messages, Python's
    BaseHTTPServer does not use any configuration files. If you want a web server
    which uses a configuration file, you will need to write the code to read and
    parse that configuration file.

    :) David
  • Shanti bhushan at Jun 15, 2010 at 3:30 am

    On Jun 15, 5:53?am, David Zaslavsky wrote:
    On Monday 14 June 2010 6:19:33 am shanti bhushan wrote:> I want to update the configuration file for python server ,but i am
    not able to locate the python configuration file.
    What configuration file? I don't see anything in your code that reads a
    configuration file.

    :) David
    next thing is i want to know which python server will have this option
    of configuration file.
  • Stephen Hansen at Jun 15, 2010 at 3:44 am

    On 6/14/10 8:30 PM, shanti bhushan wrote:
    On Jun 15, 5:53 am, David Zaslavsky wrote:
    On Monday 14 June 2010 6:19:33 am shanti bhushan wrote:> I want to update the configuration file for python server ,but i am
    not able to locate the python configuration file.
    What configuration file? I don't see anything in your code that reads a
    configuration file.

    :) David
    next thing is i want to know which python server will have this option
    of configuration file.
    Your questions aren't making any sense.

    What configuration file? What even *is* a "python server"? What are you
    trying to configure or accomplish?

    Python is a programming language. It has no configuration (except
    certain environment variables).

    A "server" can certainly be written in Python. Or a server (Apache, and
    the like) can be configured to use Python to serve dynamic content in
    various ways (from obsolete, like CGI, to fast cgi, to mod_python, to
    the latest fad, mod_wsgi).

    More information is required for us to help you.

    --

    Stephen Hansen
    ... Also: Ixokai
    ... Mail: me+list/python (AT) ixokai (DOT) io
    ... Blog: http://meh.ixokai.io/

    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: signature.asc
    Type: application/pgp-signature
    Size: 487 bytes
    Desc: OpenPGP digital signature
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100614/8fe8febf/attachment.pgp>

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 14, '10 at 10:19a
activeJun 15, '10 at 9:30p
posts6
users3
websitepython.org

People

Translate

site design / logo © 2022 Grokbase