-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (23 loc) · 799 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
from fastapi import FastAPI
from fastapi.responses import HTMLResponse, StreamingResponse, Response
from libs.mcserver import Mcserver
from starlette.responses import FileResponse
from dotenv import load_dotenv
app = FastAPI()
load_dotenv()
@app.get("/")
async def root():
return FileResponse("doc/index.html")
@app.get("/server/{host}")
@app.get("/server/{host}:{port}")
@app.get("/i/{d}")
async def get_img(host: str = 'qcminecraft.com', port: int = 25565, srv: bool = False, d=False):
if d:
server = Mcserver('qcminecraft.com', srv=True)
else:
server = Mcserver(host, port, srv)
img = server.get_img().getvalue()
return Response(img, media_type="image/png")
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)