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 import create_engine, Column, Integer, String, TEXT
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
|
from fastapi.staticfiles import StaticFiles
|
||||||
|
|
||||||
# Declare Base and setup tables
|
# Declare Base and setup tables
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
@@ -44,6 +45,7 @@ session = Session()
|
|||||||
|
|
||||||
# Initialize FastAPI and setup routes
|
# Initialize FastAPI and setup routes
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
app.mount("/static", StaticFiles(directory='static'), name='static')
|
||||||
|
|
||||||
|
|
||||||
@app.get('/')
|
@app.get('/')
|
||||||
@@ -52,9 +54,9 @@ async def root():
|
|||||||
|
|
||||||
|
|
||||||
@app.post('/checkin/')
|
@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)
|
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:
|
try:
|
||||||
session.commit()
|
session.commit()
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
aiofiles==0.7.0
|
||||||
asgiref==3.3.4
|
asgiref==3.3.4
|
||||||
click==8.0.1
|
click==8.0.1
|
||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
|
|||||||
Reference in New Issue
Block a user