forked from railwayapp-templates/flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
25 lines (16 loc) · 875 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from flask import Flask, jsonify
import os
import chromadb
app = Flask(__name__)
client = chromadb.HttpClient(
host=os.getenv('CHROMA_DB_HOST', 'chroma.railway.internal'),
settings=chromadb.config.Settings(chroma_client_auth_provider="chromadb.auth.token.TokenAuthClientProvider",
chroma_client_auth_credentials=os.getenv('CHROMA_DB_AUTH_CREDENTIALS')))
client.heartbeat() # this should work with or without authentication - it is a public endpoint
client.get_version() # this should work with or without authentication - it is a public endpoint
client.list_collections() # this is a protected endpoint and requires authentication
@app.route('/')
def index():
return jsonify({"Choo Choo": "Welcome to your Flask app 🚅"})
if __name__ == '__main__':
app.run(debug=True, port=os.getenv("PORT", default=5000))