Programmatical uvicorn start

This commit is contained in:
inexcode 2022-08-12 17:43:04 +04:00
parent a96f6bd067
commit 43675b2d1d
3 changed files with 8 additions and 3 deletions

View file

@ -1,3 +1,3 @@
[build-system] [build-system]
requires = ["setuptools", "wheel", "portalocker", "flask-swagger", "flask-swagger-ui"] requires = ["setuptools", "wheel", "portalocker"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"

View file

@ -5,6 +5,8 @@ from fastapi import FastAPI, Depends, Request, WebSocket, BackgroundTasks
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from strawberry.fastapi import BaseContext, GraphQLRouter from strawberry.fastapi import BaseContext, GraphQLRouter
import uvicorn
from selfprivacy_api.dependencies import get_api_version, get_graphql_context from selfprivacy_api.dependencies import get_api_version, get_graphql_context
from selfprivacy_api.graphql.schema import schema from selfprivacy_api.graphql.schema import schema
from selfprivacy_api.migrations import run_migrations from selfprivacy_api.migrations import run_migrations
@ -49,3 +51,6 @@ async def get_version():
async def startup(): async def startup():
run_migrations() run_migrations()
init_restic() init_restic()
if __name__ == "__main__":
uvicorn.run("app:app", host="0.0.0.0", port=5050, log_level="info")

View file

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name="selfprivacy_api", name="selfprivacy_api",
version="1.2.7", version="2.0.0",
packages=find_packages(), packages=find_packages(),
scripts=[ scripts=[
"selfprivacy_api/app.py", "selfprivacy_api/app.py",