24 lines
753 B
Python
24 lines
753 B
Python
|
from app.database import engine
|
||
|
from app.models import Base
|
||
|
import uvicorn
|
||
|
import argparse # Importuj argparse
|
||
|
|
||
|
def main(port):
|
||
|
# Create the database
|
||
|
print("Creating database tables...")
|
||
|
Base.metadata.create_all(bind=engine)
|
||
|
print("Database tables created.")
|
||
|
|
||
|
# Uruchomienie aplikacji FastAPI za pomocą uvicorn
|
||
|
uvicorn.run("app.main:app", host="0.0.0.0", port=port, reload=True)
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
# Utwórz parser argumentów
|
||
|
parser = argparse.ArgumentParser(description="Run the FastAPI app")
|
||
|
# Dodaj argument port, domyślnie 9999
|
||
|
parser.add_argument("--port", type=int, default=9999, help="Port to run the FastAPI app on")
|
||
|
# Parsuj argumenty
|
||
|
args = parser.parse_args()
|
||
|
|
||
|
main(args.port)
|