You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
wowstash/wowstash/run.py

52 lines
1.3 KiB

from flask import Flask, jsonify, request, make_response, render_template, session, redirect, url_for, escape
from flask_session import Session
from datetime import timedelta, datetime
from redis import Redis
from wowstash.library.jsonrpc import daemon
from wowstash.library.info import info
from wowstash import config
# from wowstash.blueprints.account import account_bp
# from wowstash.blueprints.authentication import authentication_bp
# Setup app
app = Flask(__name__)
app.config.from_envvar('FLASK_SECRETS')
app.secret_key = app.config['SECRET_KEY']
# Setup sessions
app.config['SESSION_REDIS'] = Redis(
host=app.config['REDIS_HOST'],
port=app.config['REDIS_PORT']
)
sess = Session()
sess.init_app(app)
# app.register_blueprint(account_bp)
# app.register_blueprint(authentication_bp)
@app.route('/')
def index():
return render_template('home.html', node=daemon.info(), info=info.get_info())
@app.route('/health')
def health():
print(dir(info.redis))
return make_response(jsonify({
'cache': info.redis.ping(),
'db': False
}), 200)
@app.errorhandler(404)
def not_found(error):
return make_response(jsonify({
'error': 'Page not found'
}), 404)
@app.cli.command('eviscerate')
def eviscerate():
print('Eviscerate the proletariat')
if __name__ == '__main__':
app.run()