# config.py
class Config(object):
TESTING = False
# И еще конфиги разные
class ProductionConfig(Config):
DEBUG = False
LOGFILE = 'logs/Production.log'
class DevelopmentConfig(Config):
DEBUG = True
LOGFILE = 'logs/Development.log'
# app.py
from logging.handlers import RotatingFileHandler
from logging import Formatter
import logging
app = Flask(__name__)
app.config.from_object('config.DevelopmentConfig')
# -----------------------------------------------------------------------------
# Включение, отключение и ротация логов.
# -----------------------------------------------------------------------------
handler = RotatingFileHandler(app.config['LOGFILE'],
maxBytes=1000000, backupCount=1)
handler.setLevel(logging.DEBUG)
handler.setFormatter(Formatter('%(asctime)s %(levelname)s: %(message)s '
'[in %(pathname)s:%(lineno)d]'))
# logging.disable(logging.CRITICAL) # Расскоментарь это для прекращения логов
app.logger.addHandler(handler)
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
app.logger.info("My message")
return 'Hello, World!'
if __name__ == "__main__":
app.run(debug=True)
cur = dbm.UserStat.find({'_id': 119510}, {'stat.17581': 1})
context = mobile903
[mobile903]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Dial(SIP/979035550055,60,m(default)tw)
exten => s,n,Hangup
return render_template('js_post.html', payload=payload)
$.post('http://external.com', {'key':'value'}, function(data){
window.location = data.redirect;
});
openvpn всё равно же только через root работает
user nobody
group nobody
функции, которая преобразует имя изображения в md5
app.config['TEMPLATES_AUTO_RELOAD'] = True
@app.after_request
def add_header(response):
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
response.headers['Cache-Control'] = 'public, max-age=0'
return response
debug=True
*/5 * * * * cd /your/path/to/app && /your/path/to/app/your_script_name.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import ssl, socket
hostname = sys.argv[1:][0]
ctx = ssl.create_default_context()
s = ctx.wrap_socket(socket.socket(), server_hostname=hostname)
s.connect((hostname, 443))
cert = s.getpeercert()
subject = dict(x[0] for x in cert['subject'])
issuer = dict(x[0] for x in cert['issuer'])
print(subject)
print(issuer)
# python check_sert.py thawte.com
{'organizationalUnitName': u'Infrastructure Operations', 'organizationName': u'Thawte, Inc.', 'businessCategory': u'Private Organization', 'serialNumber': u'3898261', 'commonName': u'www.thawte.com', 'stateOrProvinceName': u'California', 'countryName': u'US', '1.3.6.1.4.1.311.60.2.1.2': u'Delaware', '1.3.6.1.4.1.311.60.2.1.3': u'US', 'localityName': u'Mountain View'}
{'countryName': u'US', 'commonName': u'thawte EV SSL CA - G3', 'organizationName': u'thawte, Inc.'}
# python check_sert.py toster.ru
{'organizationalUnitName': u'PositiveSSL', 'commonName': u'toster.ru'}
{'countryName': u'GB', 'commonName': u'COMODO RSA Domain Validation Secure Server CA', 'organizationName': u'COMODO CA Limited', 'localityName': u'Salford', 'stateOrProvinceName': u'Greater Manchester'}