Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
| import shutil | |
| import os | |
| import sys | |
| import subprocess | |
| import re | |
| # Settings | |
| root_folder = 'C:/Users/Robert/Videos/YouTube/Playlists/' | |
| destination_regex = re.compile(r'^\[download\] Destination: (.*)$', re.M) |
| def sift3(s1,s2, maxOffset): | |
| s1L = len(s1) | |
| s2L = len(s2) | |
| if not s1: | |
| return (not s2 and 0 or s2L) | |
| if not s2: | |
| return s1L | |
| c1 = 0 | |
| c2 = 0 | |
| lcs = 0 |
| # This code is under the MIT license. | |
| # Inspired by this StackOverflow question: | |
| http://stackoverflow.com/questions/3295405/creating-django-objects-with-a-random-primary-key | |
| import struct | |
| from Crypto.Cipher import DES | |
| from django.db import models | |
| def base36encode(number): |
| upstream uwsgi { | |
| ip_hash; | |
| server 127.0.0.1:40000; | |
| } | |
| server { | |
| listen 80; | |
| server_name www.domain.com; | |
| root /sites/mysite/; | |
| access_log /sites/mysite/log/nginx/access.log; |
| from socialregistration.signals import connect as profile_connect | |
| from userena.managers import ASSIGNED_PERMISSIONS | |
| @receiver(socialregistration_signals.connect, sender = FacebookProfile, dispatch_uid = 'facebook.connect') | |
| def social_connect_callback(sender, user, profile, client, **kwargs): | |
| """ | |
| Create a profile for this user after connecting | |
| """ | |
| # Create a userena user. |
| worker_processes 2; | |
| error_log /var/log/nginx/error.log; | |
| pid /var/run/nginx.pid; | |
| events { | |
| worker_connections 1024; | |
| use epoll; | |
| } |
| # -*- coding: UTF-8 -*- | |
| from flaskext.wtf import Form, TextField, PasswordField, RecaptchaField, \ | |
| AnyOf, NoneOf, Regexp, Email, Required, EqualTo, Recaptcha | |
| from wtforms.validators import StopValidation | |
| from flask import request, session | |
| import model | |
| # 身份證字號格式驗證 | |
| def check_ID(form, field): | |
| locations = dict(zip([c for c in 'ABCDEFGHJKLMNPQRSTUVXYWZIO'], range(10,36))) |
| // Based off example code from Hal Robertson | |
| // https://github.com/halrobertson/test-restify-passport-facebook | |
| // See discussion: https://groups.google.com/forum/?fromgroups#!topic/passportjs/zCz0nXB_gao | |
| var restify = require('restify') | |
| // config vars | |
| var FB_LOGIN_PATH = '/api/facebook_login' | |
| var FB_CALLBACK_PATH = '/api/facebook_callback' | |
| var FB_APPID = '<<YOUR APPID HERE>>' |