Taka005 commited on
Commit
aed902d
·
1 Parent(s): 63289f1

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -10
main.py CHANGED
@@ -14,10 +14,9 @@ BASE_GD_IMAGE = Image.open("images/base-gd.png")
14
  BASE_FLIPPED_IMAGE = Image.open("images/base-gd-flipped.png")
15
  BASE_IMAGE = Image.open("images/base.png")
16
  MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
17
- branding = "Change this to the text of your choice"
18
- BaseURL = "https://api.example.com/"
19
 
20
- def draw_text(im, ofs, string, font="fonts/MPLUSRounded1c-Regular.ttf", size=16, color=(0, 0, 0, 255), split_len=None, padding=4, auto_expand=False, disable_dot_wrap=False):
21
  draw = ImageDraw.Draw(im)
22
  fontObj = ImageFont.truetype(font, size=size)
23
 
@@ -77,7 +76,7 @@ def draw_text(im, ofs, string, font="fonts/MPLUSRounded1c-Regular.ttf", size=16,
77
 
78
  return (0, dy, real_y)
79
 
80
- def gen(name, tag, id, content, icon):
81
  img = BASE_IMAGE.copy()
82
 
83
  icon = Image.open(io.BytesIO(requests.get(icon).content))
@@ -171,7 +170,7 @@ def reversemake(name, tag, id, content, icon):
171
 
172
  app = Flask(__name__)
173
 
174
- @app.route("/original", methods=["GET"])
175
  def original():
176
  res = make(
177
  request.args.get("name") or "SAMPLE",
@@ -183,7 +182,7 @@ def original():
183
  )
184
  return send_file(res, mimetype="image/png")
185
 
186
- @app.route("/colour", methods=["GET"])
187
  def colour():
188
  res = colourmake(
189
  request.args.get("name") or "SAMPLE",
@@ -207,9 +206,5 @@ def reverse():
207
  )
208
  return send_file(res, mimetype="image/png")
209
 
210
- @app.route("/", methods=["GET"])
211
- def main():
212
- return 'API URL: ' + BaseURL + '<br><br>Endpoints<br>/original Original B&W MiaQ image<br>/colour MiaQ image with coloured icon<br>/reverse MiaQ image with flipped icon position<br><br>Query Parameters<br>name: Username<br>tag: Tag<br>id: User ID<br>icon: Icon URL<br>content: Message Content<br><br>Host your own API here! (https://github.com/maamokun/miq-api)<br>Original code from Taka005 (https://github.com/Taka005/miq)'
213
-
214
  if __name__ == "__main__":
215
  app.run(host="0.0.0.0", port=3000)
 
14
  BASE_FLIPPED_IMAGE = Image.open("images/base-gd-flipped.png")
15
  BASE_IMAGE = Image.open("images/base.png")
16
  MPLUS_FONT = ImageFont.truetype("fonts/MPLUSRounded1c-Regular.ttf", size=16)
17
+ branding = "TakasumiBOT"
 
18
 
19
+ def draw_text(im, ofs, string, font="fonts/MPLUSRounded1c-Regular.ttf", size=16, color=(0, 0, 0, 255), split_len=None, padding=4, auto_expand=False, disable_dot_wrap=False):
20
  draw = ImageDraw.Draw(im)
21
  fontObj = ImageFont.truetype(font, size=size)
22
 
 
76
 
77
  return (0, dy, real_y)
78
 
79
+ def make(name, tag, id, content, icon):
80
  img = BASE_IMAGE.copy()
81
 
82
  icon = Image.open(io.BytesIO(requests.get(icon).content))
 
170
 
171
  app = Flask(__name__)
172
 
173
+ @app.route("/", methods=["GET"])
174
  def original():
175
  res = make(
176
  request.args.get("name") or "SAMPLE",
 
182
  )
183
  return send_file(res, mimetype="image/png")
184
 
185
+ @app.route("/color", methods=["GET"])
186
  def colour():
187
  res = colourmake(
188
  request.args.get("name") or "SAMPLE",
 
206
  )
207
  return send_file(res, mimetype="image/png")
208
 
 
 
 
 
209
  if __name__ == "__main__":
210
  app.run(host="0.0.0.0", port=3000)