Makes-Innovation-Hub / code-genie-server

server for code genie
MIT License
0 stars 0 forks source link

code-genie-server

server for code genie

folder structure for the project

code-genie-server/
│
├── server.py            # Entry point for the FastAPI server
├── routes/              # API routes # Define API endpoints
├── db/                  # Database-related files, Database models, CRUD operations, Database connection management
├── services/            # Business logic and services, Interactions with OpenAI API
├── utils/               # Utility functions
├── tests/               # Unit and integration tests, test_services.py
├── .env                 # Environment variables
├── requirements.txt     # Python dependencies
└── README.md            # Project documentation

Environment Variables (Explanation)

The following environment variables are stored in .env. Loading and usage of these variables is explained in Usage

Environment Variables (Usage)

To load environment variables from a .env file in Python, you can use the python-dotenv package. Here’s how you can do it:

  1. Save an .env file in your project. WARNING: make sure it is found in .gitignore. Save the above Variables in the .env file using the exact provided names.

  2. Install the python-dotenv package (if you haven’t already):

    pip install python-dotenv
    
  3. A brief example on how to load a specific environment variable:

    from dotenv import load_dotenv
    from globals import globals
    
    # Load the appropriate .env file
    if globals.env_status == "dev":
      load_dotenv('.env.dev')
    else:
      load_dotenv('.env.prod')
    
    mongodb_host = os.getenv('MONGODB_HOST')

Command-Line Arguments

Running the Server

Running in Development Environment

To run the server in the dev environment (default), use the following command:

python server.py

Or explicitly specify the environment:

python server.py --env dev

This will start the server on 127.0.0.1 (localhost) at port 8002.

Running in Production Environment

To run the server in the prod environment, use the following command:

python server.py --env prod

This will start the server on 127.0.0.1 (localhost) at port 8001.