Skip to content

Instantly share code, notes, and snippets.

@anandtripathi5
Created February 5, 2022 18:15
Show Gist options
  • Save anandtripathi5/8a136ef2788dcbf6bcf6943846c8768a to your computer and use it in GitHub Desktop.
Save anandtripathi5/8a136ef2788dcbf6bcf6943846c8768a to your computer and use it in GitHub Desktop.
Flask application with pydantic as configuration
from flask import Flask
from dotenv import load_dotenv
from config import settings
load_dotenv() # take environment variables from .env.
app = Flask(__name__)
@app.get("/")
async def hello_world():
template = f'''
<p>Hello, {vars(settings)}!</p>
'''
return template
if __name__ == '__main__':
app.run(port=settings.port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment