Added static file stuff.
This commit is contained in:
6
main.py
6
main.py
@@ -3,6 +3,7 @@ from isbnlib import meta
|
||||
from sqlalchemy import create_engine, Column, Integer, String, TEXT
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
# Declare Base and setup tables
|
||||
Base = declarative_base()
|
||||
@@ -44,6 +45,7 @@ session = Session()
|
||||
|
||||
# Initialize FastAPI and setup routes
|
||||
app = FastAPI()
|
||||
app.mount("/static", StaticFiles(directory='static'), name='static')
|
||||
|
||||
|
||||
@app.get('/')
|
||||
@@ -52,9 +54,9 @@ async def root():
|
||||
|
||||
|
||||
@app.post('/checkin/')
|
||||
async def checkin(isbn: str = Form(...), locationid: int = Form(...)):
|
||||
async def checkin(isbn: str = Form(...), locationid: int = Form(...), userid: int = Form(...)):
|
||||
info = await getMeta(isbn)
|
||||
session.add(Book(userid=1, Title=info['Title'], Author=info['Authors'], locationid=locationid))
|
||||
session.add(Book(userid=userid, Title=info['Title'], Author=info['Authors'], locationid=locationid))
|
||||
try:
|
||||
session.commit()
|
||||
except:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
aiofiles==0.7.0
|
||||
asgiref==3.3.4
|
||||
click==8.0.1
|
||||
colorama==0.4.4
|
||||
|
||||
Reference in New Issue
Block a user