Created
October 25, 2023 18:47
-
-
Save zachduda/342eabd48f408fc24894966c4bcff9f1 to your computer and use it in GitHub Desktop.
python uvicorn & fastapi default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging | |
from binascii import a2b_base64 | |
from pydantic import BaseModel | |
from fastapi.staticfiles import StaticFiles | |
from fastapi.middleware.cors import CORSMiddleware | |
from fastapi.responses import HTMLResponse, FileResponse | |
from fastapi import Body, Depends, FastAPI, HTTPException, Depends, status | |
import settings | |
app = FastAPI() | |
@app.api_route("/{path_name:path}", methods=["GET"]) | |
async def serve(path_name : str=None): | |
return FileResponse(path=os.path.join(settings.static_folder, 'index.html')) | |
if __name__ == '__main__': | |
import uvicorn | |
uvicorn.run(app, host='0.0.0.0', port=5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment