473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Http server

so far this works

<code>
import cherrypy
import os.path

class Http:

def index(self):
f = open(os.path.join(os.path.dirname(__file__), '../htm/index.htm'))
xml = f.read()
f.close()
return xml
index.exposed = True

cherrypy.tree.mount(Http())

if __name__ == '__main__':
cherrypy.config.update(os.path.join(os.path.dirnam e(__file__),
'server.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()
</code>

I would like a cute secretary for Christmas but i dont think i will
get one. So i need to find a way to scan a directory. And map all
files inside the directory and generate a class member like

<code>
def filename(self):
f = open(os.path.join(os.path.dirname(__file__), '../htm/filename'))
xml = f.read()
f.close()
return xml
filename.exposed = True
</code>

Any idea or cute secretary maybe ?
Dec 19 '06 #1
4 1561
Gert Cuykens wrote:
so far this works

<code>
import cherrypy
import os.path

class Http:

def index(self):
f = open(os.path.join(os.path.dirname(__file__), '../htm/index.htm'))
xml = f.read()
f.close()
return xml
index.exposed = True

cherrypy.tree.mount(Http())

if __name__ == '__main__':
cherrypy.config.update(os.path.join(os.path.dirnam e(__file__),
'server.conf'))
cherrypy.server.quickstart()
cherrypy.engine.start()
</code>

I would like a cute secretary for Christmas but i dont think i will
get one. So i need to find a way to scan a directory. And map all
files inside the directory and generate a class member like

<code>
def filename(self):
f = open(os.path.join(os.path.dirname(__file__), '../htm/filename'))
xml = f.read()
f.close()
return xml
filename.exposed = True
</code>

Any idea or cute secretary maybe ?
The cute secretary's name is "cherrypy.tools.staticdir".
Check out her resume at http://www.cherrypy.org/wiki/StaticContent
Robert Brewer
System Architect
Amor Ministries
fu******@amor.org

Dec 19 '06 #2
The cute secretary's name is "cherrypy.tools.staticdir".
Check out her resume at http://www.cherrypy.org/wiki/StaticContent
I think i am in love :)
Dec 19 '06 #3
The cute secretary's name is "cherrypy.tools.staticdir".
Check out her resume at http://www.cherrypy.org/wiki/StaticContent

I think i am in love :)
Cant believe this just works out

<code>
import os.path
import cherrypy
pwd = os.path.dirname(os.path.abspath(__file__))

class Http:

_cp_config = {'tools.sessions.on': True}
@cherrypy.expose
def index(self):
f = open(os.path.join(pwd, '../htm/index.htm'))
xml = f.read()
f.close()
return xml

if __name__ == '__main__':
cherrypy.config.update({'server.socket_port': 8080,
'server.thread_pool': 10,
'environment': 'production',
'log.screen': True})
conf = {'/': {'tools.staticdir.root': os.path.join(pwd, '../htm')},
'/css': {'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(pwd, '../css')},
'/js': {'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(pwd, '../js')}}
cherrypy.quickstart(Http(), '/', config=conf)
</code>
Dec 19 '06 #4
Does anybody know how to redirect a post request ?

i have a js file that does a post request to a /php/action.php file
and i would like for the secretary to just do the action method
instead that is defined in her python Http class book, so i can run
both php and python without changing the static source code at 2
different ports head to head to see witch one can handle the most
requests ?
Dec 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Erik Johnson | last post by:
Hi, I am trying to spawn a daemon type program to go off on its own and do some work (asynchoronously) from within an HTTPServer, but I am running into a problem where the web browser (actually...
7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
30
by: Anon | last post by:
If Http headers specify the character encoding, what is the point of the Meta tag specifying it?
5
by: Henrik | last post by:
Hi, I am trying to read some industrial webservers using the HTTP/CGI webequest like this: wrs = (HttpWebRequest)WebRequest.Create(HTTP/CGI-string); mwst = (HttpWebResponse wrs.GetResponse();...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
5
by: David Lozzi | last post by:
Howdy, I wrote a web service in .Net for my customer. My customer has another vendor who now has to consume it but they are not using Visual Studio. Most of their pages are jsp, and they said...
4
by: jens Jensen | last post by:
Hello, I was given the task to build a .Net client that will talk to IBM integration server via HTTP post. The idea is that each http packet exchange should be authenticated via X09 "client...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
3
by: fniles | last post by:
In our ASP page, we call XMLHttp to download XML files. When calling our page using localhost (localhost/myWebSite/myPage.htm), it works, but when calling using the IP address of the web server...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.