web.py

webpy, how to extra add data to a form?

懵懂的女人 提交于 2019-12-08 01:20:20
问题 i need a form with "records" generated from the db. For each DB record, in addition to form fields, it need to contain also images & record description, e.g. <tr> <td> rec 15, <img src=fnamex.jpg>, <input name=inp15> <checkbox name=chk15> </td> </tr> so i'm confused about the how, when & where to create the form: should the form generation method occur in my "model.py" ? in the template ? how do I keep all the element of a "record" together for later iteration in the template ? where should i

Is there a web.py for python3 yet?

落爺英雄遲暮 提交于 2019-12-07 05:53:45
问题 when I try to install with pip3: $ pip3 install web.py I receive an error: Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-i9tahb62/web.py/ I see old support forums stating that the web.py has not yet updated, but it's coming, and their github has a python3 and py3 branch. Yet, I can't find any documentation on web.py python3 version. 回答1: The web.py project is now publishing a pre-release version to PyPI that is Python 3 compatible; install it with: pip

How to initialize session data in automated test? (python 2.7, webpy, nosetests)

久未见 提交于 2019-12-07 01:16:32
I have a web application that uses session data to determine what to do next. The application is running in the browser and does what it shall do. I'd like to write an automated test to have that knowledge for future projects. The last hours I failed miserable to initialize (and hand over) session data within my test. Also I couldn't find the answer for such a basic case on the web. However, here is the app code: import web from project import code urls = ( "/page", "/Page", "/", "Index" ) app = web.application(urls, globals()) # Little hack so that debug mode works with sessions. if web

I get 'ImportError: No module named web' despite the fact that it is installed

*爱你&永不变心* 提交于 2019-12-06 15:18:50
问题 I would like to run a simple 'Hello world' app. Every time I run it I get 'ImportError: No module named web' I installed web.py using pip and using easy_install several times. I tried uninstalling it and installing again. I tried installing it a as sudo. Nothing seems to work. I use OS X Code of the application: import web urls = ( '/', 'index' ) app = web.application(urls, globals()) class index: def GET(self): greeting = "Hello World" return greeting if __name__ == "__main__": app.run() I

web.py database select access

此生再无相见时 提交于 2019-12-06 04:32:39
问题 I have been messing around with web.py lately and wanted to grab some stuff from a db and its returning me a "Storage" object. an the code i am using to call my info is: db = web.database(dbn='sqlite', db='sqlfile.sqlite') sely = db.select('carp', order="id ASC") when sely runs it drops me out text like so: <Storage {'lvl': 0, 'symbol': u'formb', 'logged': u'false', 'id': 1, 'display': u'Classic'}> when you print out sely the storage line comes out. how can i get the dictionary out of this

tornado加载CSS后无效果

十年热恋 提交于 2019-12-05 22:11:52
用tornado做了一个简单的页面。结果页面中的css被加载了,但是没有效果。用谷歌浏览器调试,说是Resource interpreted as Stylesheet but transferred with MIME type application/x-css。大概意思就是css文件被识别为样式表了,但是传输的时候是以application/x-css格式。这样就造成浏览器不能正常显示页面,css完全不起作用。原因就是,tornadod中的web.py在设置content_type时会调用 mimetypes.guess_type() 而mimetypes在初始化的时候,如果是windows环境下,就会读取本地的注册表。 因此只要把注册表中,css文件的Content Type由applicntion/x-css 改为text/css即可。 来源: https://my.oschina.net/u/3021599/blog/3134712

How to obtain JSON value from Post in a web.py server app?

我与影子孤独终老i 提交于 2019-12-05 18:43:38
Am using Python 2.7.6 along with web.py server to experiment with some simple Rest calls... Wish to send a JSON payload to my server and then print the value of the payload... Sample payload {"name":"Joe"} Here's my python script #!/usr/bin/env python import web import json urls = ( '/hello/', 'index' ) class index: def POST(self): # How to obtain the name key and then print the value? print "Hello " + value + "!" if __name__ == '__main__': app = web.application(urls, globals()) app.run() Here's my cURL command: curl -H "Content-Type: application/json" -X POST -d '{"name":"Joe"}' http:/

web.py and gunicorn

孤者浪人 提交于 2019-12-05 14:40:05
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). 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 via WSGI. web.py is a framework for creating Python web apps using WSGI. So you don't really need a tutorial

Is there a web.py for python3 yet?

放肆的年华 提交于 2019-12-05 09:39:18
when I try to install with pip3: $ pip3 install web.py I receive an error: Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-i9tahb62/web.py/ I see old support forums stating that the web.py has not yet updated, but it's coming, and their github has a python3 and py3 branch. Yet, I can't find any documentation on web.py python3 version. The web.py project is now publishing a pre-release version to PyPI that is Python 3 compatible; install it with: pip install web.py==0.40-dev1 as outlined in their Getting Started section . You can also install the latest pre

Building HTML with templates versus building it in javascript?

别来无恙 提交于 2019-12-05 08:32:22
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 that are rendered with templates, and some that are built in javascript, and even one horrid case where