Questions tagged [bottle]

Bottle is a fast, simple and lightweight WSGI micro web-framework for Python. It is distributed as a single file module and has no dependencies other than the Python Standard Library.

Bottle

Bottle is a fast, simple and lightweight micro web-framework for . It is distributed as a single file module and has no dependencies other than the Python Standard Library.

Bottle is designed for prototyping and building small web applications and services. It allows you to get things done quickly, but misses some of the advanced features and ready-to-use solutions found in other frameworks (such as MVC, ORM, form validation, scaffolding and XML-RPC).

Features

  • Routing: Requests to function-call mapping with support for clean and dynamic URLs.
  • Templates: Fast and pythonic built-in template engine and support for mako, jinja2 and cheetah templates.
  • Utilities: Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata.
  • Server: Built-in HTTP development server and support for paste, fapws3, bjoern, gae, cherrypy or any other WSGI capable HTTP server.

Resources

1487 questions
132
votes
8 answers

How to open a URL in python

import urllib fun open(): return urllib.urlopen('http://example.com') But when example.com opens it does not render CSS or JavaScript. How can I open the webpage in a web browser? @error(404) def error404(error): return…
shamsee
  • 1,329
  • 2
  • 10
  • 6
93
votes
6 answers

"getaddrinfo failed", what does that mean?

File "C:\Python27\lib\socket.py", line 224, in meth return getattr(self._sock,name)(*args) gaierror: [Errno 11004] getaddrinfo failed Getting this error when launching the hello world sample from here: http://bottlepy.org/docs/dev/
Blub
  • 13,014
  • 18
  • 75
  • 102
80
votes
5 answers

Is there a way to log python print statements in gunicorn?

With my Procfile like this: web: gunicorn app:app \ --bind "$HOST:$PORT" \ --error-logfile "-" \ --enable-stdio-inheritance \ --reload \ --log-level "debug" is it in any way possible to get python print statements to be logged…
kontur
  • 4,934
  • 2
  • 36
  • 62
41
votes
7 answers

Convert mongodb return object to dictionary

I'm using the bottle framework together with mongoengine. I have an orders model : class OrderDetail(Option): orderDetailsQty = FloatField() def to_dict(self): return mongo_to_dict_helper(self) class Order(Document): userName…
mahesmohan
  • 784
  • 1
  • 13
  • 33
40
votes
6 answers

Bottle framework and OOP, using method instead of function

I've done some coding with Bottle. It's really simple and fits my needs. However, I got stick when I tried to wrap the application into a class : import bottle app = bottle class App(): def __init__(self,param): self.param = param …
user1129665
37
votes
2 answers

How do I return a JSON array with Bottle?

I'm writing an API using Bottle, which so far has been fantastic. However, I've run up against a small hurdle when trying to return a JSON array. Here's my test app code: from bottle import route, run @route('/single') def returnsingle(): …
Mark Bell
  • 28,985
  • 26
  • 118
  • 145
36
votes
4 answers

How can I get Bottle to restart on file change?

I'm really enjoying Bottle so far, but the fact that I have to CTRL+C out of the server and restart it every time I make a code change is a big hit on my productivity. I've thought about using Watchdog to keep track of files changing then restarting…
Hubro
  • 56,214
  • 69
  • 228
  • 381
32
votes
12 answers

Bottle web framework - How to stop?

When starting a bottle webserver without a thread or a subprocess, there's no problem. To exit the bottle app -> CTRL + c. In a thread, how can I programmatically stop the bottle web server ? I didn't find a stop() method or something like that in…
Sandro Munda
  • 39,921
  • 24
  • 98
  • 123
31
votes
2 answers

How to get callback when key expires in REDIS

I'm developing application using Bottle. In my registration form, I'm confirming email by mail with a unique key. I'm storing this key in REDIS with expiry of 4 days. If user does not confirm email within 4 days, key gets expired. for this, I want…
Kartik Rokde
  • 3,633
  • 8
  • 27
  • 33
30
votes
3 answers

Setting HTTP status code in Bottle?

How do I set the HTTP status code of my response in Bottle? from bottle import app, run, route, Response @route('/') def f(): Response.status = 300 # also tried `Response.status_code = 300` return dict(hello='world') '''StripPathMiddleware…
Foo Stack
  • 2,185
  • 7
  • 24
  • 25
27
votes
4 answers

Nginx - Rewrite the request_uri before uwsgi_pass

I have a Nginx vhost than is configured as such: ... location /one { include uwsgi_params; uwsgi_pass unix:///.../one.sock; } location /two { include uwsgi_params; uwsgi_pass unix:///.../two.sock } ... This is a simplified configuration of…
shkschneider
  • 17,833
  • 13
  • 59
  • 112
26
votes
5 answers

Bottle and Json

How do I go about returning json data from a bottle request handler. I see a dict2json method in the bottle src but I am not sure how to use it. What is in the documentation: @route('/spam') def spam(): return {'status':'online',…
arinte
  • 3,660
  • 10
  • 45
  • 65
26
votes
1 answer

Python bottle module causes "Error: 413 Request Entity Too Large"

Using Python's module bottle, I'm getting HTTP 413 error when posting requests of body size > bottle's internal MEMFILE_MAX constant. Minimal working example is shown below. Server part (server.py): from bottle import * @post('/test') def test(): …
Tregoreg
  • 18,872
  • 15
  • 48
  • 69
26
votes
4 answers

How to retrieve GET vars in python bottle app

I'm trying to make a simple REST api using the Python bottle app. I'm facing a problem in retrieving the GET variables from the request global object. Any suggestions how to retrieve this from the GET request?
Maanas Royy
  • 1,522
  • 1
  • 17
  • 30
25
votes
4 answers

Bottle Py: Enabling CORS for jQuery AJAX requests

I'm working on a RESTful API of a web service on the Bottle Web Framework and want to access the resources with jQuery AJAX calls. Using a REST client, the resource interfaces work as intended and properly handle GET, POST, ... requests. But when…
Joern
  • 479
  • 1
  • 8
  • 14
1
2 3
99 100