-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
45 lines (30 loc) · 1.05 KB
/
app.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
from flask import Flask, render_template, request, send_file, redirect
from flask_assets import Environment
from werkzeug.security import safe_join
from module.utils.dotaprofile import DotaProfile
from services.assets import bundles
app = Flask(__name__)
assets = Environment(app)
assets.register(bundles)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
SteamID = request.form['steam_link']
img_dir = DotaProfile(SteamID).export()
return redirect(f'/card/{img_dir}')
return render_template('index.html')
@app.route('/img/<path:filename>.png')
def serve_image(filename):
img_path = safe_join('cards', f'{filename}.png')
return send_file(img_path)
@app.route('/card/<path:filename>')
def card(filename):
return render_template('image.html', img=filename)
@app.errorhandler(404)
def error404(error):
return render_template('404.html'), 404
@app.errorhandler(500)
def error500(error):
return render_template('500.html'), 500
if __name__ == '__main__':
app.run(debug=True)