web.py

Terminating a uwsgi worker programmatically

独自空忆成欢 提交于 2020-01-16 20:10:12
问题 In my application I need to "simulate" a HTTP timeout. Simply put, in this scenario: client -> myapp -> server client makes a HTTP POST connection to myapp which forwards it to server . However, server does not respond due to network issues or similar problems. I am stuck with an open TCP session from client which I'll need to drop. My application uses web.py, nginx and uwsgi. I cannot return a custom HTTP error such as 418 I am a teapot - it has to be a connection timeout to mirror server 's

Terminating a uwsgi worker programmatically

大城市里の小女人 提交于 2020-01-16 20:08:07
问题 In my application I need to "simulate" a HTTP timeout. Simply put, in this scenario: client -> myapp -> server client makes a HTTP POST connection to myapp which forwards it to server . However, server does not respond due to network issues or similar problems. I am stuck with an open TCP session from client which I'll need to drop. My application uses web.py, nginx and uwsgi. I cannot return a custom HTTP error such as 418 I am a teapot - it has to be a connection timeout to mirror server 's

web.py running main twice, ignoring changes

守給你的承諾、 提交于 2020-01-06 18:06:15
问题 I have a simple web.py app that reads a config file and serves to URL paths. However I get two strange behaviors. One, changes made to data in the Main are not reflected in the results of GET. Two, Main appears to run twice. Desired behavior is modifying data in Main will cause methods to see modified data, and not having main re-run. Questions: What is really happening here, that mydict is not modified in either GET. Why am I getting some code running twice. Simplest path to desired behavior

WEBPY / Serving static files : 'StaticApp Object has no attribute 'directory'

微笑、不失礼 提交于 2020-01-04 05:16:08
问题 i've got some issues serving files on my web.py application : Python 3.7 web.py ver0.40_Dev1 Eclipse Photon Release (4.8.0) app.py : import web render = web.template.render('templates/') urls = ( '/', 'index',) class index: def GET(self): return render.index() if __name__ == "__main__": app = web.application(urls, globals()) app.run() templates/index.html : <html> <h2>HELLO</h2> <img src = "/static/image.png"> </html> I manually created /templates and /static folders And I get the following

Trying to subclass but getting object.__init__() takes no parameters

隐身守侯 提交于 2020-01-04 03:50:48
问题 I'm trying to subclass web.form.Form from the webpy framework to change the behavior (it renders from in a table). I tried doing it in this way: class SyssecForm(web.form.Form): def __init__(self, *inputs, **kw): super(SyssecForm, self).__init__(*inputs, **kw) def render(self): out='<div id="form"> ' for i in self.inputs: html = utils.safeunicode(i.pre) + i.render() + self.rendernote(i.note) + utils.safeunicode(i.post) out += "%s"%(html) out += '"<div id="%s"> %s %s</div>'% (i.id, net.websafe

InternalError: current transaction is aborted, commands ignored until end of transaction block

被刻印的时光 ゝ 提交于 2020-01-04 02:35:14
问题 I'm getting this error when doing database calls in a sub process using multiprocessing library. Visit : Pastie InternalError: current transaction is aborted, commands ignored until end of transaction block this is to a Postgre Database, using psycopg2 driver in web.py . However if I use threading.Thread instead of multiprocessing.Process I don't get this error. Any idea how to fix this? 回答1: multiprocessing works (on UNIX systems) by forking the current process. If you have an existing

log incoming ip addresses in web.py

柔情痞子 提交于 2020-01-03 01:28:13
问题 I'd like to log the IP addresses of machines that access my web.py application. How can I access this data within the web.py framework? I'm happy to send the address to my own logger. 回答1: Use web.ctx['ip'] to get the remote ip address. Here is a link which explains what's in the context. 来源: https://stackoverflow.com/questions/5347484/log-incoming-ip-addresses-in-web-py

How do I use python for web development without relying on a framework?

一笑奈何 提交于 2019-12-29 10:17:07
问题 I know the various frameworks have their benefits, but I personally want my web development in python to be as straight-forward as possible: less writing to the framework, more writing python . The only thing I have found so far that lets me do this in the most obvious way possible is web.py but I have slight concerns on its performance. For those of you using nginx(or another flavour)+mod_wsgi+web.py... how's performance? Can it be improved further? For those of you who have used web.py,

Web.py “Hello world” not working - ERR_ADDRESS_INVALID

跟風遠走 提交于 2019-12-26 15:30:04
问题 I'm trying to get the "Hello World" example for Web.py working and it's giving me an error: This person seemed to be having the same issue in 2011 and the sole response suggested it might be a firewall issue. I have tried setting a new port as described here and it made no difference. I know that the new port I tried (5000) is not blocked by any firewall on my computer, so this isn't a firewall issue. 回答1: 0.0.0.0 is the IP address is bound to. Your server will be reachable on every interface

Web.py “Hello world” not working - ERR_ADDRESS_INVALID

被刻印的时光 ゝ 提交于 2019-12-26 15:29:13
问题 I'm trying to get the "Hello World" example for Web.py working and it's giving me an error: This person seemed to be having the same issue in 2011 and the sole response suggested it might be a firewall issue. I have tried setting a new port as described here and it made no difference. I know that the new port I tried (5000) is not blocked by any firewall on my computer, so this isn't a firewall issue. 回答1: 0.0.0.0 is the IP address is bound to. Your server will be reachable on every interface