mirror of
https://github.com/kennethreitz/flask-sslify.git
synced 2026-06-05 23:00:19 +00:00
setups
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from flask import current_app as app
|
||||
from flask import request, redirect
|
||||
|
||||
class SSLify(object):
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
self.install_sslify(self.app)
|
||||
|
||||
@classmethod
|
||||
def install_sslify(cls, app):
|
||||
|
||||
app.before_request(cls.redirect)
|
||||
|
||||
@staticmethod
|
||||
def redirect():
|
||||
if (not request.is_secure) and (not app.debug):
|
||||
url = request.url.replace('http://', 'https://')
|
||||
return redirect(url)
|
||||
@@ -0,0 +1,36 @@
|
||||
"""
|
||||
Flask-SSLify
|
||||
------------
|
||||
|
||||
This is a simple Flask extension that configures your Flask application to redirect
|
||||
all incoming requests to ``https``.
|
||||
|
||||
Redirects only occur when ``app.debug`` is ``False``.
|
||||
"""
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='Flask-SSLify',
|
||||
version='0.1.0',
|
||||
url='https://github.com/kennethreitz/flask-sslify',
|
||||
license='BSD',
|
||||
author='Kenneth Reitz',
|
||||
author_email='me@kennethreitz.com',
|
||||
description='Force SSL on your Flask app.',
|
||||
long_description=__doc__,
|
||||
py_modules=['flask_sslify'],
|
||||
zip_safe=False,
|
||||
include_package_data=True,
|
||||
platforms='any',
|
||||
install_requires=['Flask'],
|
||||
classifiers=[
|
||||
'Environment :: Web Environment',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: BSD License',
|
||||
'Operating System :: OS Independent',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
|
||||
'Topic :: Software Development :: Libraries :: Python Modules'
|
||||
]
|
||||
)
|
||||
Reference in New Issue
Block a user