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. uWSGItalks tonginx.
| # The MIT License (MIT) | |
| # Copyright (c) 2016 Vladimir Ignatev | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining | |
| # a copy of this software and associated documentation files (the "Software"), | |
| # to deal in the Software without restriction, including without limitation | |
| # the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
| # and/or sell copies of the Software, and to permit persons to whom the Software | |
| # is furnished to do so, subject to the following conditions: | |
| # |
| # !/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| __author__ = 'Diego Garcia' | |
| import tornado.web | |
| import tornado.ioloop | |
| import oauth2.tokengenerator | |
| import oauth2.grant | |
| import oauth2.store.redisdb | |
| import oauth2.store.mongodb |
| // This works on all devices/browsers, and uses IndexedDBShim as a final fallback | |
| var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; | |
| // Open (or create) the database | |
| var open = indexedDB.open("MyDatabase", 1); | |
| // Create the schema | |
| open.onupgradeneeded = function() { | |
| var db = open.result; | |
| var store = db.createObjectStore("MyObjectStore", {keyPath: "id"}); |
| // item param is an HTML element. | |
| _listenForSwipe: function (item) { | |
| var context = new Object(); | |
| item.addEventListener("MSPointerDown", function (e) { | |
| //if (e.pointerType == 2) { | |
| if (e.pointerType == "touch") { | |
| context._gestureInfos = new Object(); | |
| context._gestureInfos.started = true; |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script> | |
| <meta charset="utf-8"> | |
| <title>INDEC | Censo 2010 | Radios Censales por provincia</title> | |
| </head> | |
| <body> | |
| <h1>por fín, era hora</h1> |
| from __future__ import division | |
| from netCDF4 import Dataset | |
| import numpy as np | |
| import os | |
| PATH = '.' | |
| LL = np.loadtxt('%s/global_soils_default.txt' % PATH); | |
| LL = LL[:,2:4] | |
| OBS = np.loadtxt('%s/VIC_GRDC_Monthly_Climatology.txt' % PATH, delimiter=',', skiprows=1) |
| import win32serviceutil | |
| import win32service | |
| import win32event | |
| import servicemanager | |
| import socket | |
| import time | |
| import logging | |
| logging.basicConfig( | |
| filename = 'c:\\Temp\\hello-service.log', |
If you want to build PIL on Windows, you need to prepare few external libraries. Although some libraries did not provide static library for windows 32/64 bits then you need to build these libraries by your hand too. Also, PIL will load by python at last then you are recommended to use same compiler with python to build libraries.
| Pillow: | 1.7.8 for Python 2.7: src |
|---|
If you want to build PIL on Windows, you need to prepare few external libraries. Although some libraries did not provide static library for windows 32/64 bits then you need to build these libraries by your hand too. Also, PIL will load by python at last then you are recommended to use same compiler with python to build libraries.
| PIL: | 1.1.7 for Python 2.4 (or Pillow-1.7.8) |
|---|