Skip to content

Instantly share code, notes, and snippets.

@zachduda
Created October 25, 2023 18:47
Show Gist options
  • Save zachduda/342eabd48f408fc24894966c4bcff9f1 to your computer and use it in GitHub Desktop.
Save zachduda/342eabd48f408fc24894966c4bcff9f1 to your computer and use it in GitHub Desktop.
python uvicorn & fastapi default
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