main.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import uvicorn
  2. import logging
  3. from fastapi import Request
  4. from app import create_app
  5. from fastapi.middleware.cors import CORSMiddleware
  6. from fastapi.templating import Jinja2Templates
  7. from fastapi.responses import HTMLResponse
  8. app = create_app()
  9. templates = Jinja2Templates(directory="app/templates")
  10. origins = [
  11. "http://www.googo.org",
  12. "http://www.googo.org:8080",
  13. "http://0.0.0.0:8080",
  14. "http://googo.org:8080",
  15. "http://googo.org",
  16. "http://139.162.121.30",
  17. "http://127.0.0.1:5173",
  18. "http://localhost:5173"
  19. ]
  20. #uvicorn main:app --host 0.0.0.0 --port 8001
  21. app.add_middleware(
  22. CORSMiddleware,
  23. allow_origins=["*"],
  24. allow_credentials=True,
  25. allow_methods=["*"],
  26. allow_headers=["*"],
  27. )
  28. @app.get("/index.html", response_class=HTMLResponse)
  29. def read_index(request: Request):
  30. return templates.TemplateResponse("index.html", {"request": request})
  31. #@app.get("/ntcri_backstage/add-class.html", response_class=HTMLResponse)
  32. #def read_index(request: Request):
  33. # return templates.TemplateResponse("/ntcri_backstage/add-class.html", {"request": request})
  34. #@app.get("/ntcri_backstage/class-list.html", response_class=HTMLResponse)
  35. #def read_index(request: Request):
  36. # return templates.TemplateResponse("/ntcri_backstage/class-list.html", {"request": request})
  37. if __name__ == "__main__":
  38. uvicorn.run("main:app", host="cmm.ai", port=8088)