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

1464 questions
94
votes
1 answer

What is the difference between the declarative_base() and db.Model?

The quickstart tutorial for the Flask-SQLAlchemy plugin instructs users to create table models inheriting the db.Model class, e.g. app = Flask(__main__) db = SQLAlchemy(app) class Users(db.Model): __tablename__ = 'users' ... However, the…
drs
  • 4,828
  • 3
  • 33
  • 59
91
votes
7 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
  • 919
  • 1
  • 8
  • 6
64
votes
7 answers

ImportError: No module named 'bottle' - PyCharm

I installed bottle on python3.4 with pip install. In terminal, when I do: $ python3.4 >>>import bottle # shows no import error >>> but when I do it in PyCharm, it says "import bottle ImportError: No module named 'bottle'"
Tinno TL
  • 643
  • 1
  • 5
  • 7
63
votes
5 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
  • 11,602
  • 14
  • 63
  • 96
41
votes
4 answers

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

With my Procfile like this: web: gunicorn app:app \ --bind "$HOST:$PORT" \ --debug --error-logfile "-" \ --enable-stdio-inheritance \ --reload \ --log-level "debug" is it in any way possible to get python print statements to be…
kontur
  • 4,027
  • 1
  • 33
  • 58
37
votes
5 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
35
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
  • 27,184
  • 22
  • 109
  • 138
33
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
  • 686
  • 1
  • 11
  • 30
31
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
  • 48,322
  • 60
  • 196
  • 344
28
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
  • 1,845
  • 6
  • 22
  • 24
28
votes
11 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
  • 36,427
  • 21
  • 94
  • 117
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,408
  • 8
  • 41
  • 63
25
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
  • 16,338
  • 12
  • 55
  • 107
24
votes
5 answers

Bottle Static files

I have tried reading the docs for Bottle, however, I am still unsure about how static file serving works. I have an index.tpl file, and within it it has a css file attached to it, and it works. However, I was reading that Bottle does not…
IT Ninja
  • 5,564
  • 9
  • 37
  • 63
24
votes
2 answers

Bottle + WebSocket

is it possible to host a normal Bottle application and a WebSocket one (example: https://github.com/defnull/bottle/blob/master/docs/async.rst) in the same application (same port)? So that /ws will go to WebSocket handler and all other will be…
redman
  • 1,895
  • 4
  • 30
  • 58
1
2 3
97 98