You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
3 years ago
|
from fastapi import FastAPI,Request
|
||
|
from fastapi.middleware.cors import CORSMiddleware
|
||
|
from fastapi.responses import HTMLResponse
|
||
|
from fastapi.staticfiles import StaticFiles
|
||
|
from fastapi.templating import Jinja2Templates
|
||
|
|
||
|
def get_application():
|
||
|
_app = FastAPI(debug=False,title="MyHome",docs_url=None,redoc_url=None)
|
||
|
|
||
|
_app.add_middleware(
|
||
|
CORSMiddleware,
|
||
|
allow_origins=["*"],
|
||
|
allow_credentials=True,
|
||
|
allow_methods=["*"],
|
||
|
allow_headers=["*"],
|
||
|
)
|
||
|
return _app
|
||
|
|
||
|
app=get_application()
|
||
|
|
||
|
app.mount("/static",StaticFiles(directory="static"),name="static")
|
||
|
templates = Jinja2Templates(directory="templates")\
|
||
|
|
||
|
## TODO Сделать полноценный микроблок
|
||
|
@app.get("/")
|
||
|
def index(request:Request):
|
||
|
return templates.TemplateResponse("index.html",{"request":request})
|
||
|
|
||
|
@app.get("/resume")
|
||
|
def resume(request:Request):
|
||
|
with open("cv.py") as cv:
|
||
|
return templates.TemplateResponse("resume.html",{"request":request,"cv":cv.read()})
|
||
|
|
||
|
@app.get("/pycoral")
|
||
|
def index(request:Request):
|
||
|
return templates.TemplateResponse("pycoral.html",{"request":request})
|