I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.
- Flask is managed by
uWSGI
. uWSGI
talks tonginx
.
{{=form}} | |
{{=message}} |
import base64 | |
import os | |
from tastypie.fields import FileField | |
from django.core.files.uploadedfile import SimpleUploadedFile | |
class Base64FileField(FileField): | |
""" | |
A django-tastypie field for handling file-uploads through raw post data. | |
It uses base64 for en-/decoding the contents of the file. | |
Usage: |
#------------------------------------------------------------------------------- | |
# Name: maskedit.py | |
# Purpose: | |
# | |
# Author: Maxwell Morais ([email protected]) | |
# | |
# Created: 10/04/2013 | |
# Copyright: (c) Maxwell Morais 2013 | |
# Licence: MIT |
<?php | |
/** | |
* Ask me http://example.com/get_time.php?issue_id=hamstar-Wikimate-9&key=X7v54j | |
* Returns time | |
*/ | |
$API_KEY = "X7v54j"; | |
// TODO precons |
# SOURCE: http://stackoverflow.com/questions/2720014/upgrading-all-packages-with-pip | |
# placed here for my easy finding | |
import pip | |
from subprocess import call | |
for dist in pip.get_installed_distributions(): | |
call("pip install --upgrade " + dist.project_name, shell=True) |
test: | |
clear | |
nosetests --with-coverage --cover-package name_utils test_name_utils.py | |
clean: | |
find -regex '.*\.pyc' -exec rm {} \; | |
find -regex '.*~' -exec rm {} \; | |
.PHONY: test clean |
""" | |
Simple xml serializer. | |
@author Reimund Trost 2013 | |
Example: | |
mydict = { | |
'name': 'The Andersson\'s', | |
'size': 4, |
"Customize Flask to select a template based on some criteria." | |
import os | |
from flask import Flask, request, render_template | |
from flask.helpers import locked_cached_property | |
from jinja2 import FileSystemLoader, TemplateNotFound | |
# Import a detection utility from your project, not defined here. | |
# Takes a request object and returns True if browser is mobile. |