FAQ Database Discussion Community


Add and Subtract Buttons on Bottle Generated Webpage

python,bottle
Currently I have a bottle app that reads elements from a sqlite database and displays them in a table (using beer because well... I like beer). I want to be able to adjust a number in the table (amount) using add and subtract buttons in the table row. The buttons...

How to return error messages in JSON with Bottle HTTPError?

python,json,bottle
I have a bottle server that returns HTTPErrors as such: return HTTPError(400, "Object already exists with that name") When I receive this response in the browser, I'd like to be able to pick out the error message given. As it is right now I can see the error message in...

bottle templating

python,bottle
I recently got into bottlepy and this is pretty much my first experience with a template engine.(Prior I would simply make what I needed in traditional PHP) My question is this, let's say I have a base layout(A simple HTML/CSS layout), and, for example; a login box on the side....

Bottle does not statics and errors correctly

python,bottle
I recently switched from Flask to Bottle, and I have run into a few problems. Static files are not being routed Serving error pages with @error s not working correctly my file tree looks like: dev | |_db | |_dev.db | static | |_styles | |_js | |_script.js | |...

Comparing tuples to strings

python,sqlite,python-3.4,bottle
I am trying to retrieve a user from my sessions table in the database. In my unit test i get an error: line 138, in test_session_user self.assertEqual(nick_from_cookie, nick) AssertionError: ('Bobalooba',) != 'Bobalooba' I understand that this is because my code is returning a tuple when the test is comparing my...

how to get request body text using bottle?

python,bottle
I'm using bottle to receive POST webhook from bitbucket. The body of the POST contains info about what changed in the repo, etc. I am able to do this fine with @post('/myroute'), however I'm having trouble getting to the actual POST body data text. here is an image that shows...

Setting cookies for static files using bottle.py

python,cookies,bottle
New to python. I am using bottle.py as a web server. I have a set of static HTML files that need to be rendered on different routes. I am using static_file() function for the same. I also want to set a session based cookie for the page. SO I am...

Use same Python variable in multiple if-statements

python,if-statement,raspberry-pi,global-variables,bottle
I am having issues with my current Python script. The purpose of the 'progress' variable is take a specific value when it goes through one of the if-loops. But, the program never goes further then the first if-statement. It looks as if every if-statement makes his own variable called 'progress'....

ImportError: cannot import name secure_dumps

web2py,data-access-layer,bottle
I'm trying to use a standalone version of web2py's DAL. I have looked at a couple other posts (here and the link referenced therein) but still haven't been able to solve the problem. What I have done is copied the gluon folder from the web2py directory into my diretory, and...

Bottle Display Image using File://

python,bottle
I am trying to display the image on my local machine. I only use the website from my own machine. I am not expecting visit from outside. I found a solution here: Get Flask to show image not located in the static directory, But it doesn't work for me. I...

bottle_mysql Encoding failure

python,mysql,utf-8,character-encoding,bottle
My implementation goes like this : Centos Server, MySQL with Rails server and currently working on a new bottle application on that. I have a database that i want to share the date in both Rails and Bottle app. Some data in my DB are in greek. #!/usr/bin/env python #...

Python sqlite3 assertion error

python,python-3.x,sqlite3,pycharm,bottle
I am pretty sure the code I am doing is logical and makes sense but when I run it against my test the result comes back quite unusual, I am trying find a session from a cookie, and then use it to retrieve the user from the sessions table. I...

Limit uploaded file size in bottle [duplicate]

python,bottle
This question already has an answer here: Python bottle - How to upload media files without DOSing the server 2 answers How do I limit the size of files that users are able to upload to my server? I'm using bottle 0.12 and python 3.4....

Return Json Array with bottle

python,json,bottle
I am trying to return a Json array with Bottle. The code is: @app.get('/getmyname') def getmyname(): ret = """{ "chart": { "type": "column", }}""" return json.dumps(ret) However i get some unwanted characters in the resul which looks like this: "{\n\t\t\t\t\"chart\": {\n\t\t\t\t\t\"type\": \"column\",\n\t\t\t\t}}" How could i fix this?...

Unit testing bottle py application that uses request body results in KeyError: 'wsgi.input'

python,unit-testing,bottle
When unit testing a bottle py route function: from bottle import request, run, post @post("/blah/<boo>") def blah(boo): body = request.body.readline() return "body is %s" % body blah("booooo!") The following exception is raised: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 3, in blah File...

Bottle.py not reloading

python,windows,bottle
So... trying to follow along the Bottle To-Do list tutorial, using WinPython 3.4.3. Basically, I was having fits with the script not reloading, despite having run(host='localhost', port=8080, reloader=True, debug=True) set at the end of the file. After trying the same tutorial @ home with no problems (using Linux), I figured...

performance advantages of using bottle for routing?

python,performance,architecture,web2py,bottle
I started developing a web application based on the bottle web framework a couple of years ago. I chose Bottle at that time because it was the easiest solution to get up and running fast, and I was just working on building a prototype of an idea I had. Now,...

Bottle with CherryPy does not behave multi-threaded when same end-point is called

python,multithreading,cherrypy,bottle
As far as I know Bottle when used with CherryPy server should behave multi-threaded. I have a simple test program: from bottle import Bottle, run import time app = Bottle() @app.route('/hello') def hello(): time.sleep(5) @app.route('/hello2') def hello2(): time.sleep(5) run(app, host='0.0.0.0', server="cherrypy", port=8080) When I call localhost:8080/hello by opening 2 tabs...

How to prevent Python Bottle from reporting every request to the console?

python,bottle
I am running a server using Python Bottle. It works perfectly fine, but it logs every single request it handles to the console, which slows it down. Is there a way to instruct it not to make those logs to the console? Example code: from bottle import route, run @route('/')...

How to launch a Bottle application over a CherryPy standalone web server?

python,cherrypy,bottle
I have a python web app developed using the bottle framework. My bottle app is web API that provide methods that return JSon data, so no static content is needed. I am trying to deploy it to production using a CherryPy server which is supposed to be robust for production...

How should I use sqlalchemy session in bottle app to avoid 'Lost connection to MySQL server during query'

python,mysql,sqlalchemy,bottle,pythonanywhere
My bottle/sqlalchemy app is hosted on pythonanywhere.com, not sure if this matters, I hope not. The app throws 'Lost connection to MySQL server during query' after I leave it for a while. Then I refresh it and it works fine. Please note that I also have the same query implemented...

Unsure how to resolve this Bottle error (Python)

python,import,bottle
Here are my imports: from bottle import request, route, run, template, static_file, redirect from urllib2 import urlopen, URLError, Request from pymongo import MongoClient from config.development import config import json And here is the offending line (and another line that I think may be causing an issue): game_id = request.forms.get('game_id') request...

Python beaker session timeout minutes or seconds

python,bottle,beaker
Currently, I have set up my beaker session cookie_expires to 300. 'session.cookie_expires':300, 1.Is the 300 in minutes or seconds? 2. Will the created session will be automatically deleted after 300?...

SQLite database query (Python, Bottle)

python,sqlite,python-3.4,bottle
I'm trying to make a function where that returns the name of the logged in user if one can be identified or None if not. i want to do this by finding the session id from the cookie in the Bottle request if present, and using it to look up...

How can I refresh data from yahoo finance API every time webpage is viewed in Python?

python,bottle,yahoo-finance
I'm running a website for personal use using Bottle, a simple web server for python. I'm using this API to get market data from yahoo finance. This is a simplified version of my script (my first script with Python, btw) with comments explaining how it works. I hope this is...