-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
60 lines (46 loc) · 1.54 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import logging
from flask import Flask, render_template, session, url_for, redirect
from flask_compress import Compress
from app.routes.catalog import catalog_bp
from app.routes.manifest import manifest_blueprint
from app.routes.meta import meta_bp
from app.routes.stream import stream_bp
from app.db import database
from config import Config
app = Flask(__name__, template_folder='./templates', static_folder='./static')
app.config.from_object('config.Config')
app.register_blueprint(manifest_blueprint)
app.register_blueprint(catalog_bp)
app.register_blueprint(meta_bp)
app.register_blueprint(stream_bp)
Compress(app)
logging.basicConfig(format='%(asctime)s %(message)s')
@app.route('/')
@app.route('/configure')
def index():
"""
Render the index page
"""
manifest_url = f'{Config.PROTOCOL}://{Config.REDIRECT_URL}/manifest.json'
manifest_magnet = f'stremio://{Config.REDIRECT_URL}/manifest.json'
return render_template('index.html', logged_in=True,
manifest_url=manifest_url, manifest_magnet=manifest_magnet)
@app.route('/favicon.ico')
def favicon():
"""
Render the favicon for the app
"""
return app.send_static_file('favicon.ico')
@app.route('/callback')
def callback():
"""
Callback URL from MyAnimeList
:return: A webpage response with the manifest URL and Magnet URL
"""
return redirect(url_for('index'))
if __name__ == '__main__':
try:
from waitress import serve
serve(app, host='0.0.0.0', port=5000)
finally:
database.storage.flush()