Skip to content

mdyousufhossain/AlPhotoGeneratingApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Server Documentation

Overview

This Express.js server serves as an API for working with the DALL-E model and handling posts with associated images. It integrates with Cloudinary for image storage and retrieval and uses the OpenAI API to generate images based on prompts.

Prerequisites Before running the server, make sure you have the following dependencies installed:

  • Node.js (v14 or later)
  • NPM (Node Package Manager)
  • MongoDB (with the connection URL provided in the environment variable MONGODB_URL)
  • Cloudinary Account (with API credentials stored in environment variables ClOULDINARY_CLOUD_NAME, ClOULDINARY_API_KEY, and ClOULDINARY_API_SECRET)
  • OpenAI API Key (stored in the environment variable OPENAI_API_KEY)

Configuration

Ensure that you have set up your environment variables in a .env file in the root directory. Sample .env file:

MONGODB_URL=your-mongodb-connection-url ClOULDINARY_CLOUD_NAME=your-cloudinary-cloud-name ClOULDINARY_API_KEY=your-cloudinary-api-key ClOULDINARY_API_SECRET=your-cloudinary-api-secret OPENAI_API_KEY=your-openai-api-key

Starting the Server

run :

npm start

Your server will be available at http://localhost:8080

API Endpoints

  • 1. /api/v1/post (Post Routes)
  • GET /api/v1/post
Description: Get a list of posts stored in the MongoDB database.

Request Type: GET

  • Response:
    • Status Code: 200 OK
    • Content-Type: application/json
    Error Responses:
  • Status Code: 500 Internal Server Error
  • Content-Type: application/json

POST /api/v1/post

Description: Create a new post and store it in the MongoDB database.

  • Request Type: POST
  • Request Body:
  • Content-Type: application/json

{ "name": "Post Name", "prompt": "DALL-E Prompt", "photo": "Base64-encoded image data" }

Response

  • Status Code: 201 Created
  • Content-Type: application/json

{ "success": true, "data": { "name": "Post Name", "prompt": "DALL-E Prompt", "photo": "URL to the uploaded image" } }

WARING: Since OpenAI going wild you might have some issue while generating new image

Visit : https://al-photo-generating-app.vercel.app

exam2

exm1