Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratyush Sharma authored and Pratyush Sharma committed Feb 25, 2024
1 parent a7785f6 commit c8084af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
22 changes: 11 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
# mongo_db_url = os.environ.get("MONGO_DB_CONN_STRING")
# client = MongoClient(mongo_db_url)

# connection_string = f"mongodb://localhost:27017/wildcabarets"
# client = MongoClient(connection_string)
connection_string = f"mongodb://localhost:27017/wildcabaret"
client = MongoClient(connection_string, tlsCAFile=certifi.where())

# app.config['MONGO_URI'] = "mongodb://localhost:27017/wildcabarets"
# mongo = PyMongo(app)
app.config['MONGO_URI'] = "mongodb://localhost:27017/wildcabaret"
mongo = PyMongo(app)
# mongodb+srv://pratyush:43O86u20v1HPDL9h@superminds-cluster-7f2d92d1.mongo.ondigitalocean.com/wildcabarets?tls=true&authSource=admin&replicaSet=superminds-cluster

connection_string = f"mongodb+srv://pratyush:43O86u20v1HPDL9h@superminds-cluster-7f2d92d1.mongo.ondigitalocean.com/wildcabaret?tls=true&authSource=admin&replicaSet=superminds-cluster"
client = MongoClient(connection_string, tlsCAFile=certifi.where())
app.config['MONGO_URI'] = "mongodb+srv://pratyush:43O86u20v1HPDL9h@superminds-cluster-7f2d92d1.mongo.ondigitalocean.com/wildcabaret?tls=true&authSource=admin&replicaSet=superminds-cluster"
mongo = PyMongo(app)
# connection_string = f"mongodb+srv://pratyush:43O86u20v1HPDL9h@superminds-cluster-7f2d92d1.mongo.ondigitalocean.com/wildcabaret?tls=true&authSource=admin&replicaSet=superminds-cluster"
# client = MongoClient(connection_string, tlsCAFile=certifi.where())
# app.config['MONGO_URI'] = "mongodb+srv://pratyush:43O86u20v1HPDL9h@superminds-cluster-7f2d92d1.mongo.ondigitalocean.com/wildcabaret?tls=true&authSource=admin&replicaSet=superminds-cluster"
# mongo = PyMongo(app)

# client = MongoClient('mongodb://localhost:27017/')
client = MongoClient('mongodb://localhost:27017/')
db = client['wildcabaret']
collection = db['users']
collection1 = db['booking']
Expand Down Expand Up @@ -349,7 +349,7 @@ def get_bookings():
@app.route('/book-now/<id>', methods=['GET'])
def booking(id):
if not ObjectId.is_valid(id):
return jsonify({"error": "Invalid Object ID"}), 404 # Return 401 for invalid ID
return jsonify({"error": "Invalid Object ID"}), 404
booking = collection1.find_one({'_id':ObjectId(id)})
if booking:
booking["_id"] = str(booking["_id"])
Expand Down Expand Up @@ -1026,7 +1026,7 @@ def delete_uploaded_image(id, filename):
aws_secret_access_key=DO_SECRET_KEY,
endpoint_url=DO_SPACES_ENDPOINT)

@app.route('/delete-eventimage', methods=['POST'])
@app.route('/events/image/objectkey', methods=['DELETE'])
@jwt_required()
def delete_object():
try:
Expand Down
20 changes: 11 additions & 9 deletions static/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"application/json"
],
"responses": {
"200": {
"201": {
"description": "New User Registered",
"content": {
"application/json": {
Expand Down Expand Up @@ -1238,25 +1238,27 @@
}
}
},
"/delete-eventimage": {
"post": {
"/events/image/objectkey": {
"delete": {
"summary": "Delete image file.",
"description": "This endpoint will delete an existing image.\n\n__Usage__:\n\n1) Click on the **Try it out** button.\n\n2) Click on the **Execute** button to submit the request.\n\n3) Object_key is the filename from the file_url: https://wild-cabarets.fra1.digitaloceanspaces.com/wild-cabarets/**filename** e.g from the file_url: https://wild-cabarets.fra1.digitaloceanspaces.com/wild-cabarets/**mobile/65d5c6c0dfaedf20d9fafa96/sample.png**, **mobile/65d5c6c0dfaedf20d9fafa96/sample.png** is the object_key.\n\n**The below table defines the HTTP Status codes that this API may return**\n\n<table>\n <tr>\n <td>Status Code</td>\n <td>Description</td>\n <td>Reason</td>\n </tr>\n <tr>\n <td>200</td>\n <td>Event Image Deleted</td>\n <td>Deletes the file successfully.</td>\n </tr>\n <tr>\n <td>401</td>\n <td>Unauthorized</td>\n <td>Missing Authorization Header.</td>\n </tr>\n <tr>\n <td>404</td>\n <td>Not Found Error</td>\n <td>Event Image Not Found or Deleted.</td>\n </tr>\n <tr>\n <td>500</td>\n <td>Server Error</td>\n <td>If Internal server error occured.</td>\n </tr>\n</table>",
"description": "This endpoint will delete an existing image.\n\n__Usage__:\n\n1) Click on the **Try it out** button.\n\n2) Click on the **Execute** button to submit the request.\n\n3) Object_key is the filename from the file_url: https://wild-cabarets.fra1.digitaloceanspaces.com/wild-cabarets/**filename** \n\n**The below table defines the HTTP Status codes that this API may return**\n\n<table>\n <tr>\n <td>Status Code</td>\n <td>Description</td>\n <td>Reason</td>\n </tr>\n <tr>\n <td>200</td>\n <td>Event Image Deleted</td>\n <td>Deletes the file successfully.</td>\n </tr>\n <tr>\n <td>401</td>\n <td>Unauthorized</td>\n <td>Missing Authorization Header.</td>\n </tr>\n <tr>\n <td>404</td>\n <td>Not Found Error</td>\n <td>Event Image Not Found or Deleted.</td>\n </tr>\n <tr>\n <td>500</td>\n <td>Server Error</td>\n <td>If Internal server error occured.</td>\n </tr>\n</table>",
"security":[{"JWT": {} }],
"tags": [
"Event"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"object_key": {
"type": "string"
"type": "string",
"format": "string",
"nullable": false
}
}
},
"required": ["object_key"]
}
}
}
Expand Down

0 comments on commit c8084af

Please sign in to comment.