Compare commits
2 commits
13665ce22c
...
ae818f6a9a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae818f6a9a | ||
|
|
6be061ba04 |
19
README.md
Normal file
19
README.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Pizzatool
|
||||
```
|
||||
# create virtualenv
|
||||
virtualenv-3 venv
|
||||
# activate virtualenv
|
||||
. venv/bin/activate
|
||||
# install pizzatool
|
||||
pip install .
|
||||
# run pizzatool with frontend in frontend/<myfrontend>/dist
|
||||
pizzatool frontend/<myfrontend>/dist
|
||||
```
|
||||
|
||||
# Frontend Showdown
|
||||
For the showdown create your frontend somewhere in `frontend/<myfrontend>`.
|
||||
Running `pizzatool frontend/<myfrontend>/dist` will serve
|
||||
`frontend/<myfrontend>/dist` at `http://localhost:8000/` and the REST API at
|
||||
`http://localhost:8000/api`. You can inspect and test the API in
|
||||
`http://localhost:8000/api/docs`.
|
||||
Happy Hacking!
|
||||
|
|
@ -1,10 +1,24 @@
|
|||
from asyncio import run as asyncio_run
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi import FastAPI
|
||||
from hypercorn.config import Config
|
||||
from hypercorn.asyncio import serve
|
||||
from logging import basicConfig, DEBUG
|
||||
from pizzatool.api import app
|
||||
from pizzatool.api import app as api
|
||||
from sys import argv
|
||||
|
||||
class SinglePageApplication(StaticFiles):
|
||||
async def get_response(self, path, scope):
|
||||
response = await super().get_response(path, scope)
|
||||
if response.status_code == 404:
|
||||
response = await super().get_response('.', scope)
|
||||
return response
|
||||
|
||||
def main():
|
||||
basicConfig(level=DEBUG, format="%(levelname)s %(name)s %(message)s")
|
||||
asyncio_run(serve(app, Config()))
|
||||
app = FastAPI()
|
||||
config = Config()
|
||||
config.accesslog = '-'
|
||||
app.mount('/api', app=api)
|
||||
app.mount('/', app=SinglePageApplication(directory=argv[1], html=True))
|
||||
asyncio_run(serve(app, config))
|
||||
|
|
|
|||
3
setup.py
3
setup.py
|
|
@ -13,9 +13,10 @@ setup(
|
|||
]
|
||||
},
|
||||
install_requires=[
|
||||
'aiofiles',
|
||||
'aiosqlite',
|
||||
'fastapi',
|
||||
'hypercorn',
|
||||
'ormantic @ https://github.com/MushroomMaula/ormantic/tarball/master#egg=ormantic-0.0.32',
|
||||
'ormantic @ https://github.com/dl6tom/ormantic/tarball/bugfix__get_key_factory#egg=ormantic-0.0.32',
|
||||
]
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue