Last active
January 31, 2025 08:39
-
-
Save Larivact/1ee3bad0e53b2e2c4e40 to your computer and use it in GitHub Desktop.
Revisions
-
Larivact revised this gist
Mar 17, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ The initial portion of the request URL's "path" that corresponds to the applicat **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. Flask's routing and `url_for` are provided by [Werkzeug](http://werkzeug.pocoo.org/). Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. ## Conclusion @@ -24,7 +24,7 @@ gunicorn -e SCRIPT_NAME=/my-app my_app:app ``` **With Flask's dev server** Flask's builtin development server [`app.run()`](http://flask.pocoo.org/docs/api/#flask.Flask.run) uses [`werkzeug.serving.run_simple()`](http://werkzeug.pocoo.org/docs/serving/#werkzeug.serving.run_simple). In order to use the convenient debugging and reloading features while still serving the site under a `SCRIPT_NAME` you would have to use a WSGI middleware that sets the `SCRIPT_NAME` and trims the `PATH_INFO`. ```python from werkzeug.serving import run_simple -
Larivact revised this gist
Mar 17, 2017 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ # Serving Flask under a subpath Your Flask app object implements the `__call__` method, which means it can be called like a regular function. When your WSGI container receives a HTTP request it calls your app with the `environ` dict and the `start_response` callable. WSGI is specified in [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables). The two relevant environ variables are: **SCRIPT_NAME** The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server. -
Larivact revised this gist
Mar 17, 2017 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,21 @@ # Serving Flask under a subpath Your Flask app object implements the `__call__` method, which means it can be called like a regular function. When a HTTP request comes in your WSGI container calls your app the `environ` dict and the `start_response` callable. WSGI is specified in [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables). The two relevant environ variables are : **SCRIPT_NAME** The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server. **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. Flask's routing and `url_for` are provided by Werkzeug. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. ## Conclusion This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. **In production** How you do this depends on your [deployment option](http://flask.pocoo.org/docs/deploying/). Eg. with [Gunicorn](http://gunicorn.org/) you can pass environment variables with `-e`. -
Larivact revised this gist
Mar 17, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ The remainder of the request URL's "path", designating the virtual "location" of This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. **In production** How you do this depends on your [deployment option](http://flask.pocoo.org/docs/deploying/). Eg. with [Gunicorn](http://gunicorn.org/) you can pass environment variables with `-e`. ``` gunicorn -e SCRIPT_NAME=/my-app my_app:app ``` -
Larivact revised this gist
Mar 17, 2017 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ # Serving Flask under a subpath Your Flask app object implements the `__call__` method, which means it can be called like a regular function. When a HTTP request comes in your WSGI container calls your app with the standard WSGI parameters `environ` and `start_response`. Flask's routing and `url_for` are provided by Werkzeug. Werkzeug correctly implements [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables)'s description of the environ variables, which states: -
Larivact revised this gist
Mar 17, 2017 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Serving Flask under a sub path Your Flask app object implements the `__call__` method which means it can be called like a regular function. Your WSGI container needs access to your `app` "function", now when an HTTP request comes in the WSGI container calls our "app function" with the standard WSGI parameters `environ` and `start_response`. @@ -10,7 +10,7 @@ The initial portion of the request URL's "path" that corresponds to the applicat **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. ## Conclusion This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 13 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,18 +28,19 @@ from werkzeug.serving import run_simple from my_app import app class FixScriptName(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): SCRIPT_NAME = '/my-app' if environ['PATH_INFO'].startswith(SCRIPT_NAME): environ['PATH_INFO'] = environ['PATH_INFO'][len(SCRIPT_NAME):] environ['SCRIPT_NAME'] = SCRIPT_NAME return self.app(environ, start_response) else: start_response('404', [('Content-Type', 'text/plain')]) return ["This doesn't get served by your FixScriptName middleware.".encode()] app = FixScriptName(app) -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,10 +32,14 @@ class FixScriptName(object): self.app = app def __call__(self, environ, start_response): SCRIPT_NAME = '/my-app' if environ['PATH_INFO'].startswith(SCRIPT_NAME): environ['PATH_INFO'] = environ['PATH_INFO'][len(SCRIPT_NAME):] environ['SCRIPT_NAME'] = SCRIPT_NAME return self.app(environ, start_response) else: start_response('404', [('Content-Type', 'text/plain')]) return ["This doesn't get served by your FixScriptName middleware.".encode()] app = FixScriptName(app) -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,7 @@ class FixScriptName(object): self.app = app def __call__(self, environ, start_response): SCRIPT_NAME = '/my-app' environ['PATH_INFO'] = environ['PATH_INFO'][len(SCRIPT_NAME):] environ['SCRIPT_NAME'] = SCRIPT_NAME return self.app(environ, start_response) -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,10 @@ The remainder of the request URL's "path", designating the virtual "location" of This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. **In production** How you do this depends on your chosen [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment). For example when using [gunicorn](http://gunicorn.org/) you do it like this: ``` gunicorn -e SCRIPT_NAME=/my-app my_app:app ``` **With Flask's dev server** Flask's builtin development server [`app.run()`](http://flask.pocoo.org/docs/0.10/api/#flask.Flask.run) uses [`werkzeug.serving.run_simple()`](http://werkzeug.pocoo.org/docs/0.11/serving/#werkzeug.serving.run_simple). In order to use the convenient debugging and reloading features while still serving the site under a `SCRIPT_NAME` you would have to use a WSGI middleware that sets the `SCRIPT_NAME` and trims the `PATH_INFO`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,9 +14,10 @@ The remainder of the request URL's "path", designating the virtual "location" of This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. **In production** How you do this depends on your chosen [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment). For example when using [gunicorn](http://gunicorn.org/) you do it like this: `gunicorn -e SCRIPT_NAME=/my-app my_app:app`. **With Flask's dev server** Flask's builtin development server [`app.run()`](http://flask.pocoo.org/docs/0.10/api/#flask.Flask.run) uses [`werkzeug.serving.run_simple()`](http://werkzeug.pocoo.org/docs/0.11/serving/#werkzeug.serving.run_simple). In order to use the convenient debugging and reloading features while still serving the site under a `SCRIPT_NAME` you would have to use a WSGI middleware that sets the `SCRIPT_NAME` and trims the `PATH_INFO`. ```python -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ This means that if your application isn't located at the root of your server but How you do this depends on which [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment) you choose. For example when using [gunicorn](http://gunicorn.org/) you do it like this: `gunicorn -e SCRIPT_NAME=/my-app my_app:app`. **Using Flask's dev server** Flask's builtin development server [`app.run()`](http://flask.pocoo.org/docs/0.10/api/#flask.Flask.run) uses [`werkzeug.serving.run_simple()`](http://werkzeug.pocoo.org/docs/0.11/serving/#werkzeug.serving.run_simple). In order to use the convenient debugging and reloading features while still serving the site under a `SCRIPT_NAME` you would have to use a WSGI middleware that sets the `SCRIPT_NAME` and trims the `PATH_INFO`. ```python from werkzeug.serving import run_simple -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ This means that if your application isn't located at the root of your server but How you do this depends on which [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment) you choose. For example when using [gunicorn](http://gunicorn.org/) you do it like this: `gunicorn -e SCRIPT_NAME=/my-app my_app:app`. **Using Flask's dev server** Flask's builtin development server [`app.run()`](http://flask.pocoo.org/docs/0.10/api/#flask.Flask.run) uses `werkzeug.serving.run_simple()`. In order to use the convenient debugging and reloading features while still serving the site under a `SCRIPT_NAME` you would have to use a WSGI middleware that sets the `SCRIPT_NAME` and trims the `PATH_INFO`. ```python from werkzeug.serving import run_simple -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 23 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,4 +14,26 @@ The remainder of the request URL's "path", designating the virtual "location" of This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. How you do this depends on which [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment) you choose. For example when using [gunicorn](http://gunicorn.org/) you do it like this: `gunicorn -e SCRIPT_NAME=/my-app my_app:app`. **Using Flask's dev server** Flask's builtin development server [`app.run()`](http://flask.pocoo.org/docs/0.10/api/#flask.Flask.run) uses `werkzeug.serving.run_simple()`. In order to use the convenient debugging and reloading features while still serving the site under a `SCRIPT_NAME` you would have to use a WSGI middleware that sets the 'SCRIPT_NAME' and trims the 'PATH_INFO'. ```python from werkzeug.serving import run_simple from my_app import app class FixScriptName(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): SCRIPT_NAME = 'my-app' environ['PATH_INFO'] = environ['PATH_INFO'][len(SCRIPT_NAME):] environ['SCRIPT_NAME'] = SCRIPT_NAME return self.app(environ, start_response) app = FixScriptName(app) run_simple('0.0.0.0', 5000, app, use_reloader=True) ``` -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,8 @@ The initial portion of the request URL's "path" that corresponds to the applicat **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. ##Conclusion This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. How you do this depends on which [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment) you choose. For example when using [gunicorn](http://gunicorn.org/) you do it like this: `gunicorn -e SCRIPT_NAME=/my-app my_app:app`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,6 @@ The initial portion of the request URL's "path" that corresponds to the applicat **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. How you do this depends on which [deployment option](http://flask.pocoo.org/docs/0.10/deploying/#deployment) you choose. For example when using [gunicorn](http://gunicorn.org/) you do it like this: `gunicorn -e SCRIPT_NAME=/my-app my_app:app`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,4 @@ The initial portion of the request URL's "path" that corresponds to the applicat **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on `PATH_INFO` and its `url_for` function prepends `SCRIPT_NAME`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ Your Flask app object implements the `__call__` method which means it can be called like a regular function. Your WSGI container needs access to your `app` "function", now when an HTTP request comes in the WSGI container calls our "app function" with the standard WSGI parameters `environ` and `start_response`. Flask's routing and `url_for` are provided by Werkzeug. Werkzeug correctly implements [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables)'s description of the environ variables, which states: **SCRIPT_NAME** The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,4 +10,4 @@ The initial portion of the request URL's "path" that corresponds to the applicat **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on 'PATH_INFO' and its `url_for` function prepends `SCRIPT_NAME`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,8 @@ Your Flask app object implements the `__call__` method which means it can be cal Flask's routing and `url_for` are provided by Werkzeug. Werkzeug correctly implements [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables)'s description of the environ variables which states: **SCRIPT_NAME** The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server. **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,9 @@ Your Flask app object implements the `__call__` method which means it can be cal Flask's routing and `url_for` are provided by Werkzeug. Werkzeug correctly implements [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables)'s description of the environ variables which states: **SCRIPT_NAME** The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server. **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container that the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on 'PATH_INFO' and its `url_for` function prepends `SCRIPT_NAME`. -
Larivact revised this gist
Feb 2, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ #Serving Flask under a sub path Your Flask app object implements the `__call__` method which means it can be called like a regular function. Your WSGI container needs access to your `app` "function", now when an HTTP request comes in the WSGI container calls our "app function" with the standard WSGI parameters `environ` and `start_response`. -
Larivact renamed this gist
Feb 2, 2016 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ #Serving Flask under a different application root path Your Flask app object implements the `__call__` method which means it can be called like a regular function. Your WSGI container needs access to your `app` "function", now when an HTTP request comes in the WSGI container calls our "app function" with the standard WSGI parameters `environ` and `start_response`. Flask's routing and `url_for` are provided by Werkzeug. Werkzeug correctly implements [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables)'s description of the environ variables which states: -
Larivact created this gist
Feb 2, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ Your Flask app object implements the `__call__` method which means it can be called like a regular function. Your WSGI container needs access to your `app` "function", now when an HTTP request comes in the WSGI container calls our "app function" with the standard WSGI parameters `environ` and `start_response`. Flask's routing and `url_for` are provided by Werkzeug. Werkzeug correctly implements [PEP 0333](https://www.python.org/dev/peps/pep-0333/#environ-variables)'s description of the environ variables which states: **SCRIPT_NAME** The initial portion of the request URL's "path" that corresponds to the application object, so that the application knows its virtual "location". This may be an empty string, if the application corresponds to the "root" of the server. **PATH_INFO** The remainder of the request URL's "path", designating the virtual "location" of the request's target within the application. This may be an empty string, if the request URL targets the application root and does not have a trailing slash. This means that if your application isn't located at the root of your server but under a path you have to tell your WSGI container that the env `SCRIPT_NAME`. It will then split incoming request paths into `SCRIPT_NAME` and `PATH_INFO`. Werkzeug's routing operates on 'PATH_INFO' and its `url_for` function prepends `SCRIPT_NAME`.