mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-11-15 02:21:21 +01:00
dc7d825564
Todo and not yet fully functional yet Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing Fix Titan Dev thing
45 lines
1.4 KiB
Python
45 lines
1.4 KiB
Python
#!/usr/bin/env python2
|
|
from titanembeds.app import app
|
|
import subprocess
|
|
|
|
def init_debug():
|
|
import os
|
|
from flask import jsonify, request
|
|
|
|
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1' # Testing oauthlib
|
|
|
|
# Session viewer https://gist.github.com/babldev/502364a3f7c9bafaa6db
|
|
def decode_flask_cookie(secret_key, cookie_str):
|
|
import hashlib
|
|
from itsdangerous import URLSafeTimedSerializer
|
|
from flask.sessions import TaggedJSONSerializer
|
|
salt = 'cookie-session'
|
|
serializer = TaggedJSONSerializer()
|
|
signer_kwargs = {
|
|
'key_derivation': 'hmac',
|
|
'digest_method': hashlib.sha1
|
|
}
|
|
s = URLSafeTimedSerializer(secret_key, salt=salt, serializer=serializer, signer_kwargs=signer_kwargs)
|
|
return s.loads(cookie_str)
|
|
|
|
@app.route("/session")
|
|
def session():
|
|
cookie = request.cookies.get('session')
|
|
if cookie:
|
|
decoded = decode_flask_cookie(app.secret_key, request.cookies.get('session'))
|
|
else:
|
|
decoded = None
|
|
return jsonify(session_cookie=decoded)
|
|
|
|
@app.route("/github-update", methods=["POST"])
|
|
def github_update():
|
|
try:
|
|
subprocess.Popen("git pull", shell=True).wait()
|
|
except OSError:
|
|
return "ERROR"
|
|
|
|
return "OK"
|
|
if __name__ == "__main__":
|
|
init_debug()
|
|
app.run(host="0.0.0.0",port=3000,debug=True,processes=3)
|