main.py 1.4 KB

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