1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge branch 'ynh-patched' of github.com:JocelynDelalande/ihatemoney into ynh-pathed-upstream

Waiting for pull requests to be included upstream.
This commit is contained in:
Jocelyn Delande 2015-05-01 14:35:25 +02:00
commit 4037139ac8
3 changed files with 39 additions and 4 deletions

View file

@ -27,7 +27,7 @@ the following content::
DEBUG = True DEBUG = True
SQLACHEMY_ECHO = DEBUG SQLACHEMY_ECHO = DEBUG
You can also set the `TESTING` flag to `True` so no mails are sent You can also set the `TESTING` flag to `True` so no mails are sent
(and no exception is raised) while you're on development mode. (and no exception is raised) while you're on development mode.
Deploy it Deploy it
@ -48,7 +48,12 @@ To deploy it, I'm using gunicorn and supervisord::
Don't forget to set the right permission for your files ! Don't forget to set the right permission for your files !
Also, create a `settings.py` file with the appropriate values if you need to Also, create a `settings.py` file with the appropriate values if you need to
use a different database for instance. use a different database for instance. You can also set `APPLICATION_ROOT` if
you want to prefix your URLs to serve ihatemonney in the *folder* of a domain,
e.g:
APPLICATION_ROOT='/budget'
How about the REST API? How about the REST API?
======================= =======================
@ -66,7 +71,7 @@ As a developer
-------------- --------------
The best way to contribute code is to write it and to make a pull request on The best way to contribute code is to write it and to make a pull request on
github. Please, think about updating and running the tests before asking for github. Please, think about updating and running the tests before asking for
a pull request as it will help us to maintain the code clean and running. a pull request as it will help us to maintain the code clean and running.
To do so:: To do so::

View file

@ -4,10 +4,11 @@ from raven.contrib.flask import Sentry
from web import main, db, mail from web import main, db, mail
from api import api from api import api
from utils import ReverseProxied
app = Flask(__name__) app = Flask(__name__)
app.config.from_object("default_settings") app.config.from_object("default_settings")
app.wsgi_app = ReverseProxied(app.wsgi_app, app.config['APPLICATION_ROOT'])
app.register_blueprint(main) app.register_blueprint(main)
app.register_blueprint(api) app.register_blueprint(api)

View file

@ -32,3 +32,32 @@ class Redirect303(HTTPException, RoutingException):
def get_response(self, environ): def get_response(self, environ):
return redirect(self.new_url, 303) return redirect(self.new_url, 303)
class ReverseProxied(object):
'''
Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
Inspired from http://flask.pocoo.org/snippets/35/
:param app: the WSGI application
'''
def __init__(self, app, prefix):
self.app = app
self.prefix = prefix
def __call__(self, environ, start_response):
script_name = self.prefix
if script_name:
environ['SCRIPT_NAME'] = script_name
path_info = environ['PATH_INFO']
if path_info.startswith(script_name):
environ['PATH_INFO'] = path_info[len(script_name):]
scheme = environ.get('HTTP_X_SCHEME', '')
if scheme:
environ['wsgi.url_scheme'] = scheme
return self.app(environ, start_response)