-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
36 lines (29 loc) · 919 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
from fastapi import FastAPI
from fastapi import Query
from fastapi.responses import PlainTextResponse
from jsmin import jsmin
from fastapi.middleware.cors import CORSMiddleware
from execute import compile
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allow all origins
allow_credentials=True,
allow_methods=["*"], # Allow all methods (GET, POST, etc.)
allow_headers=["*"], # Allow all headers
)
def readfile():
with open('execjs/javascript.js', 'r') as file:
file_contents = file.read()
return file_contents
@app.get("/", response_class=PlainTextResponse)
async def bridge():
minified_js = jsmin(readfile())
return minified_js
@app.get("/compile/")
async def compile_css(var: str = Query(...)):
print(f"Received CSS content: {var}")
return compile(var)
@app.get("/health")
async def health_check():
return {"status": "ok"}