web.py

including script doesn't work in web.py

自作多情 提交于 2019-12-25 08:57:45
问题 everyone.I wanna include javascript in the html(webpy templates),but it doesn't work.the javascript code in the html works very well... following is the main python file(main.py): urls = ('/main','main') render = web.template.render('templates/') class main: def GET(self): return render.main() app = web.application(urls,globals()) if __name__ == "__main__": app.run() templates/main.htm: <body> <script type="text/javascript" src="include.js"></script> <script> alert(location.href); //this line

how to run background job in web.py?

五迷三道 提交于 2019-12-25 07:47:57
问题 I use web.py to process incoming data by "GET" and "POST" method and uses app.run() . This looks will run in loop and never stop. I also have a background job which detect port "9xxx" and process the incoming data, send msg to other servers to push msg to phone. I also uses a while(true) loop to do this. How to integrate (2) into (1)? I'm confused. I used to plan run (1) and (2) independently but there has data exchange so not convenience to code. how do you web.py users do these similar

Python Extracting binary from a POST request using web.py

。_饼干妹妹 提交于 2019-12-24 19:19:02
问题 I am developing an API that allows outside clients to send a binary file which will be processed. my web.data() is a string and the function I am calling requires a binary. How do I get it into the correct format? Maybe I have the incorrect Headers? how do I extract the binary data. I am using web.py. -----------------POST request---------------------------------------------------- import json import requests files = {'file':('000038fe4b46c210c37bdde767835007', open(

Web.py routing seems to keep breaking

拥有回忆 提交于 2019-12-24 18:52:10
问题 For some reason, every time I run my web app it comes up with new errors, either it can't find my pages, or Attribute errors, or KeyErrors and I don't know why. I'm following a tutorial written a while back, and some web.py rules may have changed, but I can't figure out why this isn't working. Here is my controller.py file: import web urls = { '/', 'Home', '/register', 'Register', '/postregistration', 'PostRegistration' } render = web.template.render('Views/Templates', base='MainLayout') #

web.py & beaker python app. page render issues

无人久伴 提交于 2019-12-24 11:37:18
问题 I have been using web.py recently to try and create an web app, an issue became apparent that we did not have a way of creating multiple sessions, I have tried using beaker (https://github.com/bbangert/beaker) to manage the multiple sessions, but now I have run into an issue of rendering the home page, does anyone have an idea of how to fix this? the error we continue to get is " BLAH BLAH BLAH BLAH Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/web

In Peewee I have a datetime field defaulted to datetime.datetime.now(). But when inserted, it takes the time the server was started. Why

半城伤御伤魂 提交于 2019-12-23 12:10:05
问题 When I insert a row, the field is filled with the time when the server was started not the time when the row was inserted. Why is this happening and what is the solution? BTW I am using SQLite. class LOG(peewee.Model): id = peewee.IntegerField(unique=True,primary_key=True) timestamp = peewee.DateTimeField(default=datetime.datetime.now()) log = peewee.CharField() by = peewee.IntegerField(default=1) class Meta: database = database LOG.create(log = _log , by = _by) # above statement is called at

Arguments to web.py handler classes

不想你离开。 提交于 2019-12-23 09:32:04
问题 Is there any way to pass arguments to web.py handler class constructors? E.g. These arguments might come from the command line (when the main web.py script is run), after the first arg (which is taken as the port number) 回答1: Sure, depending on exactly what you mean. It's all python after all. Consider you have available web.config which is a Storage object which is visible everywhere. I regularly use that to place system-wide configuration information (& alter debugging output as you'll see

web.py and gunicorn

﹥>﹥吖頭↗ 提交于 2019-12-22 09:07:07
问题 My question is basically what's in the title: how can I setup gunicorn to run a web.py app? (Also, if there are any differences, how would I do it on heroku?) I already have my app running on heroku using the built in cherrypy, but I have not been able to get gunicorn to work with web.py (I just have no idea where to start - I couldn't find any tutorials). 回答1: I'm afraid I'm not familar with Heroku, but I can answer your basic question. gunicorn is a HTTP server for running Python web apps

Building HTML with templates versus building it in javascript?

淺唱寂寞╮ 提交于 2019-12-22 06:18:07
问题 I recently started making web apps, and while I make some stuff that works, I'm not sure of the best practices. Up to now, I've mostly used the templating systems of Django, web.py and PHP. But now that I'm using jQuery and nice ajaxy magic to get data from the server without refreshing the client, I'm seeing the advantages of building the HTML directly in javascript (so I can just send a small json object to the client and have him figure out what to change and how). So now I have some bits

Building HTML with templates versus building it in javascript?

限于喜欢 提交于 2019-12-22 06:17:38
问题 I recently started making web apps, and while I make some stuff that works, I'm not sure of the best practices. Up to now, I've mostly used the templating systems of Django, web.py and PHP. But now that I'm using jQuery and nice ajaxy magic to get data from the server without refreshing the client, I'm seeing the advantages of building the HTML directly in javascript (so I can just send a small json object to the client and have him figure out what to change and how). So now I have some bits