File tree Expand file tree Collapse file tree 6 files changed +18
-8146
lines changed
Expand file tree Collapse file tree 6 files changed +18
-8146
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1616* .egg-info /
1717.installed.cfg
1818* .egg
19+ .coverage
1920
2021# Serverless directories
2122.serverless
Original file line number Diff line number Diff line change 11import os
22
3- from flask import Flask , render_template
4-
3+ from fastapi import FastAPI , Request
4+ from fastapi .templating import Jinja2Templates
5+ from fastapi .responses import HTMLResponse
6+ from mangum import Mangum
57from pynamodb .models import Model
68from pynamodb .attributes import UnicodeAttribute
79
8- app = Flask (__name__ )
910
11+ app = FastAPI ()
12+ templates = Jinja2Templates (directory = "templates" )
1013class OneTable (Model ):
1114 '''
1215 DynamoDB works best with a single table. This table. Use this table to model
1316 other data requests.
1417 '''
1518 class Meta :
16- table_name = os . environ [ 'DYNAMODB_TABLE_NAME' ]
19+ table_name = 'DYNAMODB_TABLE_NAME'
1720
1821 pk = UnicodeAttribute (hash_key = True )
1922 sk = UnicodeAttribute (range_key = True )
2023
21- @app .route ("/" )
22- def cats ():
23- return render_template ( ' index.html' )
24+ @app .get ("/" , response_class = HTMLResponse )
25+ def cats (request : Request ):
26+ return templates . TemplateResponse ( " index.html" , { "request" : request } )
2427
25- @app .route ("/dogs/<id> " )
28+ @app .get ("/dogs/{id} " )
2629def dog (id ):
2730 return "Dog"
2831
29- @app .route ("/health" )
32+ @app .get ("/health" )
3033def health ():
31- return { "status" : "Success" }
34+ return {"status" : "Success" }
35+
36+ handler = Mangum (app )
You can’t perform that action at this time.
0 commit comments