Questions tagged [werkzeug]

Werkzeug is a WSGI utility library for Python. It's widely used and BSD licensed.

Werkzeug is a WSGI utility library for Python. It includes a debugger and fully featured request response headers. Also included is a set of HTTP utilities.

624 questions
1235
votes
24 answers

Get the data received in a Flask request

I want to be able to get the data sent to my Flask app. I've tried accessing request.data but it is an empty string. How do you access request data? from flask import request @app.route('/', methods=['GET', 'POST']) def parse_request(): data =…
ddinchev
  • 33,683
  • 28
  • 88
  • 133
685
votes
18 answers

Configure Flask dev server to be visible across the network

I'm not sure if this is Flask specific, but when I run an app in dev mode (http://localhost:5000), I cannot access it from other machines on the network (with http://[dev-host-ip]:5000). With Rails in dev mode, for example, it works fine. I couldn't…
sa125
  • 28,121
  • 38
  • 111
  • 153
321
votes
12 answers

Get IP address of visitors using Flask for Python

I'm making a website where users can log on and download files, using the Flask micro-framework (based on Werkzeug) which uses Python (2.6 in my case). I need to get the IP address of users when they log on (for logging purposes). Does anyone know…
Jon Cox
  • 10,622
  • 22
  • 78
  • 123
159
votes
4 answers

Get raw POST body in Python Flask regardless of Content-Type header

Previously, I asked How to get data received in Flask request because request.data was empty. The answer explained that request.data is the raw post body, but will be empty if form data is parsed. How can I get the raw post body…
ddinchev
  • 33,683
  • 28
  • 88
  • 133
108
votes
4 answers

What exactly is Werkzeug?

From the official documentation: Werkzeug is a WSGI utility library for Python. However, when I run my Flask web application, I notice that the response header from the server contains: HTTP/1.0 200 OK Content-Type: text/html;…
jinglei
  • 3,269
  • 11
  • 27
  • 46
94
votes
3 answers

Is the server bundled with Flask safe to use in production?

Is the server bundled with Flask safe for deployment in a production environment? If not, what should I use to deploy Flask in production?
ensnare
  • 40,069
  • 64
  • 158
  • 224
81
votes
4 answers

RuntimeError: working outside of application context

app.py from flask import Flask, render_template, request,jsonify,json,g import mysql.connector app = Flask(__name__) class TestMySQL(): @app.before_request def before_request(): try: g.db =…
guri
  • 1,521
  • 2
  • 14
  • 20
73
votes
8 answers

Flask url_for generating http URL instead of https

I am using url_for to generate a redirect URL when a user has logged out: return redirect(url_for('.index', _external=True)) However, when I changed the page to a https connection, the url_for still gives me http. I would like to explicitly ask…
Blaise
  • 7,230
  • 6
  • 43
  • 53
57
votes
2 answers

Getting the array as GET query parameters in Python

I know in php I could just use $_GET['key1']['key2'] to retrieve GET data that is sent in the form of an array but is that something possible in Python as I just receive a string and it's not recognized as an array/list. I use flask/werkzeug if that…
Romeo M.
  • 3,218
  • 8
  • 35
  • 40
48
votes
2 answers

Flask and Werkzeug: Testing a post request with custom headers

I'm currently testing my app with suggestions from http://flask.pocoo.org/docs/testing/, but I would like to add a header to a post request. My request is currently: self.app.post('/v0/scenes/test/foo', data=dict(image=(StringIO('fake image'),…
theicfire
  • 2,719
  • 2
  • 26
  • 29
46
votes
3 answers

How do I use url_for if my method has multiple route annotations?

So I have a method that is accessible by multiple routes: @app.route("/canonical/path/") @app.route("/alternate/path/") def foo(): return "hi!" Now, how can I call url_for("foo") and know that I will get the first route?
jiggy
  • 3,828
  • 1
  • 25
  • 40
42
votes
1 answer

Capture arbitrary path in Flask route

I have a simple Flask route that I want to capture a path to a file. If I use in the rule, it works for /get_dir/one but not /get_dir/one/two. How can I capture an arbitrary path, so that path='/one/two/etc will be passed to the view…
Darwin Tech
  • 18,449
  • 38
  • 112
  • 187
40
votes
4 answers

104, 'Connection reset by peer' socket error, or When does closing a socket result in a RST rather than FIN?

We're developing a Python web service and a client web site in parallel. When we make an HTTP request from the client to the service, one call consistently raises a socket.error in socket.py, in read: (104, 'Connection reset by peer') When I listen…
jwhitlock
  • 4,572
  • 4
  • 39
  • 49
38
votes
4 answers

ImportError: cannot import name 'parse_rule' from 'werkzeug.routing'

I got the following message after running my Flask project on another system. The application ran all the time without problems: Error: While importing 'app', an ImportError was raised: Traceback (most recent call last): File…
ChsharpNewbie
  • 1,040
  • 3
  • 9
  • 21
38
votes
3 answers

Handling large file uploads with Flask

What would be the best way to handle very large file uploads (1 GB +) with Flask? My application essentially takes multiple files assigns them one unique file number and then saves it on the server depending on where the user selected. How can we…
Infinity8
  • 615
  • 2
  • 9
  • 24
1
2 3
41 42