-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
40 lines (32 loc) · 955 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
36
37
38
39
40
from flask import Flask, Response
from json import load
from os import walk
from random import choice
app = Flask('API')
url = 'https://bocchi-api.vercel.app'
@app.get('/')
def func():
for root, d, imgs in walk('./imgs/'):
img = choice(imgs)
rbee = open(f'./imgs/{img}', 'rb') # rbee
return Response(rbee, mimetype='image/jpg')
@app.get('/<img>')
def funcc(img: str):
rbee = open(f'./imgs/{img}', 'rb') # rbee
return Response(rbee, mimetype='image/jpg')
@app.get('/JSON')
def funccc():
for root, d, imgs in walk('./sauces/'):
img = choice(imgs)
JSON = load(open(f'./sauces/{img}'))
imgURL = JSON['imgURL']
JSON['imgURL'] = f'{url}/{imgURL}'
return JSON
@app.get('/JSON/<img>')
def funcccc(img: str):
JSON = load(open(f'./sauces/{img}'))
imgURL = JSON['imgURL']
JSON['imgURL'] = f'{url}/{imgURL}'
return JSON
# Un-comment this if not using vercel ;)
# app.run(port=3000)