librelist archives

« back to archive

Is there a way of serving HTTPS in Flask?

Is there a way of serving HTTPS in Flask?

From:
0byte
Date:
2013-04-27 @ 15:28
Dear all,

I couldn't find a way of making my Flask app serving HTTPS without using 
nginx or apache.
To clarify, I would like that my flask app responds and serves -> 
https://localhost:port

Any suggestion about what to do?
 

thanks

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
Check it out at http://www.inbox.com/earth

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
薛 鹏飞
Date:
2013-04-29 @ 01:34
actually, the right way to sever https is using nginx or other web server 
at the front of your flask application

				     uwsgi/http	
request -----> nginx ---------------> flask  


--
Sincerely,
Pengfei Xue
https://life-map.rhcloud.com

在 2013-4-27,下午11:28,0byte <pillone@inbox.com> 写道:

> Dear all,
> 
> I couldn't find a way of making my Flask app serving HTTPS without using
nginx or apache.
> To clarify, I would like that my flask app responds and serves -> 
https://localhost:port
> 
> Any suggestion about what to do?
> 
> 
> thanks
> 
> ____________________________________________________________
> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> Check it out at http://www.inbox.com/earth
> 
> 

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
Maple
Date:
2013-04-27 @ 15:31
let nginx works with https and flask response to requests


On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:

> Dear all,
>
> I couldn't find a way of making my Flask app serving HTTPS without using
> nginx or apache.
> To clarify, I would like that my flask app responds and serves ->
> https://localhost:port
>
> Any suggestion about what to do?
>
>
> thanks
>
> ____________________________________________________________
> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> Check it out at http://www.inbox.com/earth
>
>
>


-- 

胡淼
Sun Yat-sen University
The Guangdong Key Laboratory of Information Security Technology
Blog: http://ismaple.com/
Github: https://github.com/humiaozuzu

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
0byte
Date:
2013-04-27 @ 15:37
Thanks for the reply but it doesn't really suit my needs.

I would like to distribute this sw across platforms without the hassle of 
installing extra stuff..

> -----Original Message-----
> From: maplevalley8@gmail.com
> Sent: Sat, 27 Apr 2013 23:31:15 +0800
> To: flask@librelist.com
> Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
> 
> let nginx works with https and flask response to requests
> 
> 
> On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:
> 
>> Dear all,
>> 
>> I couldn't find a way of making my Flask app serving HTTPS without using
>> nginx or apache.
>> To clarify, I would like that my flask app responds and serves ->
>> https://localhost:port
>> 
>> Any suggestion about what to do?
>> 
>> 
>> thanks
>> 
>> ____________________________________________________________
>> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>> Check it out at http://www.inbox.com/earth
>> 
>> 
>> 
> 
> 
> --
> 
> 胡淼
> Sun Yat-sen University
> The Guangdong Key Laboratory of Information Security Technology
> Blog: http://ismaple.com/
> Github: https://github.com/humiaozuzu

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
Maple
Date:
2013-04-27 @ 15:42
Sorry, this link may help.
http://www.ianlewis.org/en/testing-https-djangos-development-server


On 27 April 2013 23:37, 0byte <pillone@inbox.com> wrote:

> Thanks for the reply but it doesn't really suit my needs.
>
> I would like to distribute this sw across platforms without the hassle of
> installing extra stuff..
>
> > -----Original Message-----
> > From: maplevalley8@gmail.com
> > Sent: Sat, 27 Apr 2013 23:31:15 +0800
> > To: flask@librelist.com
> > Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
> >
> > let nginx works with https and flask response to requests
> >
> >
> > On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:
> >
> >> Dear all,
> >>
> >> I couldn't find a way of making my Flask app serving HTTPS without using
> >> nginx or apache.
> >> To clarify, I would like that my flask app responds and serves ->
> >> https://localhost:port
> >>
> >> Any suggestion about what to do?
> >>
> >>
> >> thanks
> >>
> >> ____________________________________________________________
> >> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> >> Check it out at http://www.inbox.com/earth
> >>
> >>
> >>
> >
> >
> > --
> >
> > 胡淼
> > Sun Yat-sen University
> > The Guangdong Key Laboratory of Information Security Technology
> > Blog: http://ismaple.com/
> > Github: https://github.com/humiaozuzu
>
> ____________________________________________________________
> FREE ONLINE PHOTOSHARING - Share your photos online with your friends and
> family!
> Visit http://www.inbox.com/photosharing to find out more!
>
>
>


-- 

胡淼
Sun Yat-sen University
The Guangdong Key Laboratory of Information Security Technology
Blog: http://ismaple.com/
Github: https://github.com/humiaozuzu

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
Mark Grey
Date:
2013-04-27 @ 15:56
This is often mentioned on the mailing list, and the general consensus is
that the the extra bloat you'll incur on the python side (not to mention
the performance reduction serving static files) is worth the minimal extra
config you'll get from installing nginx.

It really isn't that bad, just set up a reverse proxy within nginx and
serve flask with something like Cherry or Gunicorn.  If you are
distributing, you can actually have nginx round robin the requests and do
elementary load balancing.  The config is trivial and it will lead to a
more performant environment.

Are you making some kind of tool that uses the browser as a UI and that's
why you're trying to do this at localhost?


On Sat, Apr 27, 2013 at 11:42 AM, Maple <maplevalley8@gmail.com> wrote:

> Sorry, this link may help.
> http://www.ianlewis.org/en/testing-https-djangos-development-server
>
>
> On 27 April 2013 23:37, 0byte <pillone@inbox.com> wrote:
>
>> Thanks for the reply but it doesn't really suit my needs.
>>
>> I would like to distribute this sw across platforms without the hassle of
>> installing extra stuff..
>>
>> > -----Original Message-----
>> > From: maplevalley8@gmail.com
>> > Sent: Sat, 27 Apr 2013 23:31:15 +0800
>> > To: flask@librelist.com
>> > Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
>> >
>> > let nginx works with https and flask response to requests
>> >
>> >
>> > On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:
>> >
>> >> Dear all,
>> >>
>> >> I couldn't find a way of making my Flask app serving HTTPS without
>> using
>> >> nginx or apache.
>> >> To clarify, I would like that my flask app responds and serves ->
>> >> https://localhost:port
>> >>
>> >> Any suggestion about what to do?
>> >>
>> >>
>> >> thanks
>> >>
>> >> ____________________________________________________________
>> >> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>> >> Check it out at http://www.inbox.com/earth
>> >>
>> >>
>> >>
>> >
>> >
>> > --
>> >
>> > 胡淼
>> > Sun Yat-sen University
>> > The Guangdong Key Laboratory of Information Security Technology
>> > Blog: http://ismaple.com/
>> > Github: https://github.com/humiaozuzu
>>
>> ____________________________________________________________
>> FREE ONLINE PHOTOSHARING - Share your photos online with your friends and
>> family!
>> Visit http://www.inbox.com/photosharing to find out more!
>>
>>
>>
>
>
> --
>
> 胡淼
> Sun Yat-sen University
> The Guangdong Key Laboratory of Information Security Technology
> Blog: http://ismaple.com/
> Github: https://github.com/humiaozuzu
>

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
0byte
Date:
2013-04-27 @ 15:52
Y,

I know about this option but requires stunnell and I would really avoid to
attach extra binaries.

The option that I am exploring is to use a ssl_context piped through 
app.run(host=hostmy,port=12233, debug = False, ssl_context=ctx)

still no win



> -----Original Message-----
> From: maplevalley8@gmail.com
> Sent: Sat, 27 Apr 2013 23:42:02 +0800
> To: flask@librelist.com
> Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
> 
> Sorry, this link may help.
> http://www.ianlewis.org/en/testing-https-djangos-development-server
> 
> 
> On 27 April 2013 23:37, 0byte <pillone@inbox.com> wrote:
> 
>> Thanks for the reply but it doesn't really suit my needs.
>> 
>> I would like to distribute this sw across platforms without the hassle
>> of
>> installing extra stuff..
>> 
>>> -----Original Message-----
>>> From: maplevalley8@gmail.com
>>> Sent: Sat, 27 Apr 2013 23:31:15 +0800
>>> To: flask@librelist.com
>>> Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
>>> 
>>> let nginx works with https and flask response to requests
>>> 
>>> 
>>> On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:
>>> 
>>>> Dear all,
>>>> 
>>>> I couldn't find a way of making my Flask app serving HTTPS without
>>>> using
>>>> nginx or apache.
>>>> To clarify, I would like that my flask app responds and serves ->
>>>> https://localhost:port
>>>> 
>>>> Any suggestion about what to do?
>>>> 
>>>> 
>>>> thanks
>>>> 
>>>> ____________________________________________________________
>>>> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>>>> Check it out at http://www.inbox.com/earth
>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> 
>>> 胡淼
>>> Sun Yat-sen University
>>> The Guangdong Key Laboratory of Information Security Technology
>>> Blog: http://ismaple.com/
>>> Github: https://github.com/humiaozuzu
>> 
>> ____________________________________________________________
>> FREE ONLINE PHOTOSHARING - Share your photos online with your friends
>> and
>> family!
>> Visit http://www.inbox.com/photosharing to find out more!
>> 
>> 
>> 
> 
> 
> --
> 
> 胡淼
> Sun Yat-sen University
> The Guangdong Key Laboratory of Information Security Technology
> Blog: http://ismaple.com/
> Github: https://github.com/humiaozuzu

____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and
most webmails

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
0byte
Date:
2013-04-27 @ 16:14
Well,

really, I would love to avoid the auto-install of my package, nginx, 
gunicorn across platforms. 

If you dig inside the guts of flask you will see that app.run just invokes
the werkzeug.run_simple that accepts 
ssl_context out of the box

see: http://werkzeug.pocoo.org/docs/serving/

the problem is that each time I try to load a https page, I get this nice 
cryptic exit error
invoked from werkzeug.BaseWSGIServer.serve_forever()

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 49081)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 311, in process_request
    self.shutdown_request(request)
  File "/usr/lib/python2.7/SocketServer.py", line 459, in shutdown_request
    request.shutdown(socket.SHUT_WR)
TypeError: shutdown() takes exactly 0 arguments (1 given)
----------------------------------------
shutdown() takes exactly 0 arguments (1 given)

> -----Original Message-----
> From: mark.asperia@gmail.com
> Sent: Sat, 27 Apr 2013 11:56:35 -0400
> To: flask@librelist.com
> Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
> 
> This is often mentioned on the mailing list, and the general consensus is
> that the the extra bloat you'll incur on the python side (not to mention
> the performance reduction serving static files) is worth the minimal
> extra
> config you'll get from installing nginx.
> 
> It really isn't that bad, just set up a reverse proxy within nginx and
> serve flask with something like Cherry or Gunicorn.  If you are
> distributing, you can actually have nginx round robin the requests and do
> elementary load balancing.  The config is trivial and it will lead to a
> more performant environment.
> 
> Are you making some kind of tool that uses the browser as a UI and that's
> why you're trying to do this at localhost?
> 
> 
> On Sat, Apr 27, 2013 at 11:42 AM, Maple <maplevalley8@gmail.com> wrote:
> 
>> Sorry, this link may help.
>> http://www.ianlewis.org/en/testing-https-djangos-development-server
>> 
>> 
>> On 27 April 2013 23:37, 0byte <pillone@inbox.com> wrote:
>> 
>>> Thanks for the reply but it doesn't really suit my needs.
>>> 
>>> I would like to distribute this sw across platforms without the hassle
>>> of
>>> installing extra stuff..
>>> 
>>>> -----Original Message-----
>>>> From: maplevalley8@gmail.com
>>>> Sent: Sat, 27 Apr 2013 23:31:15 +0800
>>>> To: flask@librelist.com
>>>> Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
>>>> 
>>>> let nginx works with https and flask response to requests
>>>> 
>>>> 
>>>> On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:
>>>> 
>>>>> Dear all,
>>>>> 
>>>>> I couldn't find a way of making my Flask app serving HTTPS without
>>> using
>>>>> nginx or apache.
>>>>> To clarify, I would like that my flask app responds and serves ->
>>>>> https://localhost:port
>>>>> 
>>>>> Any suggestion about what to do?
>>>>> 
>>>>> 
>>>>> thanks
>>>>> 
>>>>> ____________________________________________________________
>>>>> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
>>>>> Check it out at http://www.inbox.com/earth
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> --
>>>> 
>>>> 胡淼
>>>> Sun Yat-sen University
>>>> The Guangdong Key Laboratory of Information Security Technology
>>>> Blog: http://ismaple.com/
>>>> Github: https://github.com/humiaozuzu
>>> 
>>> ____________________________________________________________
>>> FREE ONLINE PHOTOSHARING - Share your photos online with your friends
>>> and
>>> family!
>>> Visit http://www.inbox.com/photosharing to find out more!
>>> 
>>> 
>>> 
>> 
>> 
>> --
>> 
>> 胡淼
>> Sun Yat-sen University
>> The Guangdong Key Laboratory of Information Security Technology
>> Blog: http://ismaple.com/
>> Github: https://github.com/humiaozuzu
>>

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!

Re: [flask] Is there a way of serving HTTPS in Flask?

From:
Mark Grey
Date:
2013-04-27 @ 17:02
True, it's just that the run() method (and werkzeug's underlying simple
server) is really, really, not intended for production traffic, nor for
static assets.  Hence why I ask if you're just trying to make a local tool
that will be sandboxed locally.

If it's not something you'll only be running locally and there will be
concurrent network users, I really implore you to use a proper production
environment.  It'll save headaches down the line.

The only other thing I can think of is the SSLContextFactory in twisted...
that's the only SSL wire encryption I've ever done in pure python.  I'm not
sure how one would utilize it with bare werkzeug but it might be worth
looking at as an approach.


On Sat, Apr 27, 2013 at 12:14 PM, 0byte <pillone@inbox.com> wrote:

> Well,
>
> really, I would love to avoid the auto-install of my package, nginx,
> gunicorn across platforms.
>
> If you dig inside the guts of flask you will see that app.run just invokes
> the werkzeug.run_simple that accepts
> ssl_context out of the box
>
> see: http://werkzeug.pocoo.org/docs/serving/
>
> the problem is that each time I try to load a https page, I get this nice
> cryptic exit error
> invoked from werkzeug.BaseWSGIServer.serve_forever()
>
> ----------------------------------------
> Exception happened during processing of request from ('127.0.0.1', 49081)
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/SocketServer.py", line 284, in
> _handle_request_noblock
>     self.process_request(request, client_address)
>   File "/usr/lib/python2.7/SocketServer.py", line 311, in process_request
>     self.shutdown_request(request)
>   File "/usr/lib/python2.7/SocketServer.py", line 459, in shutdown_request
>     request.shutdown(socket.SHUT_WR)
> TypeError: shutdown() takes exactly 0 arguments (1 given)
> ----------------------------------------
> shutdown() takes exactly 0 arguments (1 given)
>
> > -----Original Message-----
> > From: mark.asperia@gmail.com
> > Sent: Sat, 27 Apr 2013 11:56:35 -0400
> > To: flask@librelist.com
> > Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
> >
> > This is often mentioned on the mailing list, and the general consensus is
> > that the the extra bloat you'll incur on the python side (not to mention
> > the performance reduction serving static files) is worth the minimal
> > extra
> > config you'll get from installing nginx.
> >
> > It really isn't that bad, just set up a reverse proxy within nginx and
> > serve flask with something like Cherry or Gunicorn.  If you are
> > distributing, you can actually have nginx round robin the requests and do
> > elementary load balancing.  The config is trivial and it will lead to a
> > more performant environment.
> >
> > Are you making some kind of tool that uses the browser as a UI and that's
> > why you're trying to do this at localhost?
> >
> >
> > On Sat, Apr 27, 2013 at 11:42 AM, Maple <maplevalley8@gmail.com> wrote:
> >
> >> Sorry, this link may help.
> >> http://www.ianlewis.org/en/testing-https-djangos-development-server
> >>
> >>
> >> On 27 April 2013 23:37, 0byte <pillone@inbox.com> wrote:
> >>
> >>> Thanks for the reply but it doesn't really suit my needs.
> >>>
> >>> I would like to distribute this sw across platforms without the hassle
> >>> of
> >>> installing extra stuff..
> >>>
> >>>> -----Original Message-----
> >>>> From: maplevalley8@gmail.com
> >>>> Sent: Sat, 27 Apr 2013 23:31:15 +0800
> >>>> To: flask@librelist.com
> >>>> Subject: Re: [flask] Is there a way of serving HTTPS in Flask?
> >>>>
> >>>> let nginx works with https and flask response to requests
> >>>>
> >>>>
> >>>> On 27 April 2013 23:28, 0byte <pillone@inbox.com> wrote:
> >>>>
> >>>>> Dear all,
> >>>>>
> >>>>> I couldn't find a way of making my Flask app serving HTTPS without
> >>> using
> >>>>> nginx or apache.
> >>>>> To clarify, I would like that my flask app responds and serves ->
> >>>>> https://localhost:port
> >>>>>
> >>>>> Any suggestion about what to do?
> >>>>>
> >>>>>
> >>>>> thanks
> >>>>>
> >>>>> ____________________________________________________________
> >>>>> FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!
> >>>>> Check it out at http://www.inbox.com/earth
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>> --
> >>>>
> >>>> 胡淼
> >>>> Sun Yat-sen University
> >>>> The Guangdong Key Laboratory of Information Security Technology
> >>>> Blog: http://ismaple.com/
> >>>> Github: https://github.com/humiaozuzu
> >>>
> >>> ____________________________________________________________
> >>> FREE ONLINE PHOTOSHARING - Share your photos online with your friends
> >>> and
> >>> family!
> >>> Visit http://www.inbox.com/photosharing to find out more!
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >>
> >> 胡淼
> >> Sun Yat-sen University
> >> The Guangdong Key Laboratory of Information Security Technology
> >> Blog: http://ismaple.com/
> >> Github: https://github.com/humiaozuzu
> >>
>
> ____________________________________________________________
> FREE ONLINE PHOTOSHARING - Share your photos online with your friends and
> family!
> Visit http://www.inbox.com/photosharing to find out more!
>
>
>