Spaces:
Configuration error
Configuration error
Download test_mongodb.py from Waseem2106/network-security: direct link, hf CLI and curl.
- Browser
- Download file 554 Bytes
-
https://huggingface.co/spaces/Waseem2106/network-security/resolve/main/test_mongodb.py
- Command line
-
hf download hf://spaces/Waseem2106/network-security/test_mongodb.py
-
curl -L -o test_mongodb.py https://huggingface.co/spaces/Waseem2106/network-security/resolve/main/test_mongodb.py
554 Bytes
| from pymongo.mongo_client import MongoClient | |
| from pymongo.server_api import ServerApi | |
| import certifi | |
| uri = "mongodb+srv://wasimshadow12_db_user:Waseem12@cluster0.sthip0f.mongodb.net/?appName=Cluster0" | |
| # Create a new client and connect to the server | |
| client = MongoClient(uri, server_api=ServerApi('1'),tls=True,tlsCAFile=certifi.where()) | |
| # Send a ping to confirm a successful connection | |
| try: | |
| client.admin.command('ping') | |
| print("Pinged your deployment. You successfully connected to MongoDB!") | |
| except Exception as e: | |
| print(e) |