-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (24 loc) · 943 Bytes
/
main.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
from flask import Flask, render_template, request, redirect
from app import PixelArt, RunText
app = Flask(__name__)
app.static_folder = 'static'
@app.route('/', methods=["GET", "POST"])
def update():
if request.method == 'POST':
data = request.json
pixel_art = PixelArt(data)
if (not pixel_art.process()):
pixel_art.print_help()
return render_template("index.html", draw=True)
@app.route('/text', methods=["GET", "POST"])
def text():
if request.method == 'POST':
text = request.form['text']
test = request.form['color'].lstrip('#')
color = list(int(test[i:i+2], 16) for i in (0, 2, 4))
if text != "" and color != [0, 0, 0]:
runtext = RunText(text, color)
if (not runtext.process()):
runtext.print_help()
return render_template("index.html", draw=False)
app.run(debug=True, host='192.168.1.129', port="1111")