28 lines
917 B
Python
28 lines
917 B
Python
import argparse
|
|
import uvicorn
|
|
from src.users.models import User
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="User management console")
|
|
parser.add_argument("--add-user", action="store_true", help="Add a new user to the database")
|
|
parser.add_argument("--server", action="store_true", help="Run the FastAPI server")
|
|
args = parser.parse_args()
|
|
|
|
if args.add_user:
|
|
name = input("Enter username: ").strip()
|
|
password = input("Enter password: ").strip()
|
|
if name and password:
|
|
User.add_user(name, password)
|
|
else:
|
|
print("Username and password cannot be empty.")
|
|
|
|
elif args.server:
|
|
uvicorn.run(
|
|
"src:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True
|
|
)
|
|
else:
|
|
print("No action specified. Use --add-user to add a user or --server to run the server.")
|