fastapi 与 vue结合,进行前后端不分离的方式部署,返回dist文件

@app.middleware("http")
async def process_http_requests(request, call_next):
    url = str(request.url)
    print(f"Request information: {request.url}")
    if '.html' in url or '.css' in url or '.svg' in url:
        file_path = url.split(':6999')[1]
        return FileResponse(f".{file_path}")
    elif '.js' in url:
        headers = {
            "Content-Type":"application/javascript; charset=UTF-8"
        }
        file_path = url.split(':6999')[1]
        return FileResponse(f".{file_path}", headers=headers)
    else:
        response = await call_next(request)
    return response

你可能感兴趣的:(前端-vue,fastapi,vue.js,前端)