cherrypy

Uploading a file in ajax to CherryPy

不羁的心 提交于 2019-12-01 10:39:11
问题 I am trying to upload many files at once to my CherryPy server. I am following this tutorial that shows PHP code on the server side. The JavaScript part is simple. Here is a summary of what it does: function FileSelectHandler(e) { var files = e.target.files || e.dataTransfer.files; for (var i = 0, f; f = files[i]; i++) { var xhr = new XMLHttpRequest(); xhr.open("POST", "upload", true); xhr.setRequestHeader("X_FILENAME", file.name); xhr.send(file); } I translated the upload.php described in

How to stop request processing in Cherrypy?

放肆的年华 提交于 2019-12-01 08:07:49
问题 im using python 2.6, cherrypy 3.1 i have some problem with timeout of the requests. I simply need to be requests done in Limit (30 seconds). after that limit, the processes should be killed and answer returned server is starting through tree.mount(); cherrypy.start(); cherrypy.block() as first thing... when i try to kill app (by Ctrl+C (debian 6.0)), app is stuck on: Waiting for child threads to terminate... how to kill the processes on exit and how to handle the timeout connection for killin

Multiprocessing works in Ubuntu, doesn't in Windows

ぐ巨炮叔叔 提交于 2019-12-01 06:59:21
I am trying to use this example as a template for a queuing system on my cherrypy app. I was able to convert it from python 2 to python 3 (change from Queue import Empty into from queue import Empty ) and to execute it in Ubuntu. But when I execute it in Windows I get the following error: F:\workspace\test>python test.py Traceback (most recent call last): File "test.py", line 112, in <module> broker.start() File "C:\Anaconda3\lib\multiprocessing\process.py", line 105, in start self._popen = self._Popen(self) File "C:\Anaconda3\lib\multiprocessing\context.py", line 212, in _Popen return

CherryPy - saving checkboxes selection to variables

痴心易碎 提交于 2019-12-01 05:36:10
问题 I'm trying to build a simple webpage with multiple checkboxes, a Textbox and a submit buttom. I've just bumped into web programing in Python and am trying to figure out out to do it with CherryPy. I need to associate each checkbox to a variable so my .py file knows which ones were selected when clicking the 'Start button'. Can someone please give some code example ? Do I have any advantage including some Python Javascript Compiler like Pyjamas? <form action="../remote_targets/ssh_grab.py">

stopping a cherrypy server over http

岁酱吖の 提交于 2019-12-01 05:10:42
I have a cherrypy app that I'm controlling over http with a wxpython ui. I want to kill the server when the ui closes, but I don't know how to do that. Right now I'm just doing a sys.exit() on the window close event but thats resulting in Traceback (most recent call last): File "ui.py", line 67, in exitevent urllib.urlopen("http://"+server+"/?sigkill=1") File "c:\python26\lib\urllib.py", line 87, in urlopen return opener.open(url) File "c:\python26\lib\urllib.py", line 206, in open return getattr(self, name)(url) File "c:\python26\lib\urllib.py", line 354, in open_http 'got a bad status line',

How to read parameters from GET request in CherryPy?

北城余情 提交于 2019-11-30 21:38:05
How to read parameters from GET request in CherryPy ? I generate request from JQuery like $.get( "http://localhost:8080/temp", "{a:10}", function(data) { alert(data); }, "html" ); and I have class temp with @cherrypy.expose function index(self). How to extract data from GET request ? @cherrypy.expose def index(self, a) where a is your GET param As virhilo mentioned, you can take named parameters in with your method. Also, you can read cherrypy.request.params . With both POST and GET (and PUT , PATCH , etc...) you can use: cherrypy.request.params.get(key_name) Where key_name is the key name you

How to read parameters from GET request in CherryPy?

六眼飞鱼酱① 提交于 2019-11-30 17:11:35
问题 How to read parameters from GET request in CherryPy ? I generate request from JQuery like $.get( "http://localhost:8080/temp", "{a:10}", function(data) { alert(data); }, "html" ); and I have class temp with @cherrypy.expose function index(self). How to extract data from GET request ? 回答1: @cherrypy.expose def index(self, a) where a is your GET param 回答2: As virhilo mentioned, you can take named parameters in with your method. Also, you can read cherrypy.request.params . 回答3: With both POST

win32com.client.Dispatch + Cherrypy = CoInitialize has not been called

半腔热情 提交于 2019-11-30 17:08:27
问题 The following code works well, but it fails if executed from a CherryPy app method with the error message CoInitialize has not been called : import win32com.client xl = win32com.client.Dispatch("Excel.Application") xl.quit() This post suggests a solution that works for me: import pythoncom pythoncom.CoInitialize() The reason I'm asking about a problem for which I already have a solution, is that (1) I would like to know what I'm doing (rather than doing it only because I've seen it working

cherrypy.HTTPRedirect redirects to IP instead of hostname using abs path

廉价感情. 提交于 2019-11-30 17:07:24
I'm running CherryPy behind nginx and need to handle redirects. On my dev machine running on 127.0.0.1:8080, this redirects correctly to 127.0.0.1:8080/login. However when running via nginx on cherrypy.mydomain.com (port 80), the redirects are still going to 127.0.0.1:8080/login rather than cherrypy.mydomain.com/login. 127.0.0.1:8080 is the correct local address for the application, however the application server in nginx is set to listen on port 80 and pipe requests to the local cherrypy server on 127.0.0.1:8080, but shouldn't directly expose this. The relevant lines in my app are: auth

Sending JSON through requests module and catching it using bottle.py and cherrypy

北战南征 提交于 2019-11-30 16:56:26
I have a server which needs to be able to accept JSON and then process it and then send JSON back. The code at my server side is using bottle.py with cherrypy . The route in concern is the following: @route ('/tagTweets', method='POST') def tagTweets(): response.content_type = 'application/json' # here I need to be able to parse JSON send along in this request. For requesting this page and testing the functionality, I'm using requests module code: The data that I have to send is list of tweets. The data is itself fetched from some server which returns list of tweets. For fetching tweets, I'm