This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
| def cycle_key(self): | |
| #TODO: Errors here will tank the system, probably need some better handling... | |
| old_session_key = self.session_key | |
| old_session = Session.objects.get(session_key=old_session_key) | |
| try: | |
| cart = Cart.objects.get(session=old_session) | |
| super(SessionStore, self).cycle_key() | |
| new_session_key = self.session_key | |
| new_session = Session.objects.get(session_key=new_session_key) | |
| cart.session = new_session |
| <?php | |
| define('CLIENT_ID', 'YOUR_CLIENT_ID'); | |
| define('API_KEY', 'YOUR_API_KEY'); | |
| define('TOKEN_URI', 'https://connect.stripe.com/oauth/token'); | |
| define('AUTHORIZE_URI', 'https://connect.stripe.com/oauth/authorize'); | |
| if (isset($_GET['code'])) { // Redirect w/ code | |
| $code = $_GET['code']; |
| <!doctype html> | |
| <head> | |
| <title>Stripe OAuth Example</title> | |
| </head> | |
| <body> | |
| {{ token }} | |
| </body> | |
| </html> |
| def unserialize_session(val): | |
| if not val: | |
| return | |
| session = {} | |
| groups = re.split("([a-zA-Z0-9_]+)\|", val) | |
| if len(groups) > 2: | |
| groups = groups[1:] | |
| groups = map(None, *([iter(groups)] * 2)) | |
| for i in range(len(groups)): |
| <?php | |
| /** | |
| * This is an implementation of the Knuth-Morris-Pratt-Algorithm as in | |
| * Thomas H. Cormen et. al.: "Algorithmen - Eine Einführung" | |
| * (German version by Paul Molitor) 3. Auflage, page 1017 | |
| * | |
| * My changes: | |
| * - Indexes starting with 0 | |
| * - overlapping matches are recognized | |
| */ |
| class TemplatesTest(TestCase): | |
| def test_templates(self): | |
| """Templates can compile properly and there's no mismatched tags""" | |
| # get app template dirs | |
| template_dirs = [] | |
| apps = [app for app in settings.INSTALLED_APPS | |
| if app.startswith('rh2')] | |
| for app in apps: | |
| mod = import_module(app) |
The program below can take one or more plain text files as input. It works with python2 and python3.
Let's say we have two files that may contain email addresses:
foo bar
ok ideler.dennis@gmail.com sup
hey...user+123@example.com,wyd
hello world!
| #!/bin/bash | |
| NAME="hello_app" # Name of the application | |
| DJANGODIR=/webapps/hello_django/hello # Django project directory | |
| SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket | |
| USER=hello # the user to run as | |
| GROUP=webapps # the group to run as | |
| NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
| DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use | |
| DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name |