My FastAPI Application This is a FastAPI application that provides a simple JWT authentication system and uses a PostgreSQL database for storing user data.
Installation Clone the repository and navigate to the project directory:
sh Copy code git clone https://github.com/your_username/my-fastapi-app.git cd my-fastapi-app Install the required packages:
sh Copy code pip install -r requirements.txt Create a .env file in the root directory of the project, and add the following environment variables:
sh Copy code DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 DATABASE_URL=postgresql://user:password@localhost:5432/my_database SECRET_KEY=my_secret_key Replace the values with appropriate values for your environment.
Initialize the database:
sh Copy code alembic upgrade head Start the application:
sh Copy code uvicorn app.app:app --reload The application should now be accessible at http://localhost:8000.
API Documentation The API documentation is available at http://localhost:8000/docs.
API Endpoints Authentication POST /auth/register: Register a new user POST /auth/token: Get an access token POST /auth/token/refresh: Refresh an access token Users GET /users: Get a list of all users GET /users/{user_id}: Get a specific user PUT /users/{user_id}: Update a specific user DELETE /users/{user_id}: Delete a specific user