# login_manager = LoginManager(app) # login_manager.session_protection = 'basic' # 可以设置None,'basic','strong' 以提供不同的安全等级,一般设置strong,如果发现异常会登出用户 # login_manager.login_view = "/" # 这里填写你的登陆界面的路由 # login_manager.remember_cookie_duration=datetime.timedelta(days=1) # app.config.update( # PERMANENT_SESSION_LIFETIME=datetime.timedelta(seconds=12*60*60) # ) app.CSRF_ENABLED = True # CSRF_ENABLED 配置是为了激活 跨站点请求伪造 保护。在大多数情况下,你需要激活该配置使得你的应用程序更安全些 app.secret_key = 'fjusfbubvnighwwf' # SECRET_KEY 配置仅仅当 CSRF 激活的时候才需要,它是用来建立一个加密的令牌,用于验证一个表单 # 内部员工口令 inner_pass = '******' # key 用于加密 key = 15 tmp_wait_to_save_data_list = [] @app.route('/', methods=['GET', 'POST']) def login(): if request.method == 'POST': username = str(request.form.get('username'))
## declare static variables ## access tokens from twitter access_token = "4415348663-5pNNm5YQLmGrBMwWuJ1yObWbaESTIw1fNSPPDA9" access_token_secret = "gafJtISvaAdfUWuc9xsSpY2R1rHu5ICbhQEMDmqG8SWT3" consumer_secret = "1Qhn2zclLLAs82mQPEKeThJbS5CdCyYYsWtVvQi7S4oVCDdFJU" consumer_key = "6FiPNQ2wpHQSiBB58m31V0l1v" HOURS = 24 screen_name = 'NowLivecodingtv' # create the application object app = Flask(__name__) app.secret_key = "/\xfa-\x84\xfeW\xc3\xda\x11%/\x0c\xa0\xbaY\xa3\x89\x93$\xf5\x92\x9eW}" app.WTF_CSRF_SECRET_KEY = "secret_key" app.CSRF_ENABLED = True app.debug = True ## scheduler that runs every 24 hours and likes/RTs tweets sched = BlockingScheduler() @sched.scheduled_job('interval', hours = HOURS) def timed_job(): likeTweetTimelineTweets() def in24Hours(d): """function to check if the tweet is older than a day/24 hours""" age = int(time.time() - (d - datetime(1970,1,1)).total_seconds()) return age<86400 def likeTweetTimelineTweets(): """Function to like/ RT timeline tweets from the accounts being followed by
import os from flask import Flask, render_template, send_from_directory, request, flash, redirect, url_for from flask.ext.basicauth import BasicAuth app = Flask(__name__) app.secret_key = "notemetaipo" app.CSRF_ENABLED = True app.WTF_CSRF_SECRET_KEY = '*YQUIHDHQYP#*p94uUOI' app.config.update( DEBUG=True ) app.config['BASIC_AUTH_USERNAME'] = '******' app.config['BASIC_AUTH_PASSWORD'] = '' basic_auth = BasicAuth(app) @app.errorhandler(404) def page_not_found(e): return render_template('404.html'), 404 @app.route("/", methods=['GET', 'POST']) def index(): return render_template('index.html') @app.route("/basics", methods=['GET', 'POST']) @basic_auth.required def basics(): return render_template('basics.html')