content.tsx66 lines · main
| 1 | import { SimpleCodeBlock } from 'ui-patterns/SimpleCodeBlock' |
| 2 | |
| 3 | import type { ContentFileProps } from '@/components/interfaces/Connect/Connect.types' |
| 4 | import { |
| 5 | ConnectTabContent, |
| 6 | ConnectTabs, |
| 7 | ConnectTabTrigger, |
| 8 | ConnectTabTriggers, |
| 9 | } from '@/components/interfaces/Connect/ConnectTabs' |
| 10 | |
| 11 | const ContentFile = ({ projectKeys }: ContentFileProps) => { |
| 12 | return ( |
| 13 | <ConnectTabs> |
| 14 | <ConnectTabTriggers> |
| 15 | <ConnectTabTrigger value=".env" /> |
| 16 | <ConnectTabTrigger value="app.py" /> |
| 17 | </ConnectTabTriggers> |
| 18 | |
| 19 | <ConnectTabContent value=".env"> |
| 20 | <SimpleCodeBlock className="bash" parentClassName="min-h-72"> |
| 21 | {` |
| 22 | BRIVEN_URL=${projectKeys.apiUrl ?? 'your-project-url'} |
| 23 | BRIVEN_KEY=${projectKeys.publishableKey ?? projectKeys.anonKey ?? 'your-anon-key'} |
| 24 | `} |
| 25 | </SimpleCodeBlock> |
| 26 | </ConnectTabContent> |
| 27 | |
| 28 | <ConnectTabContent value="app.py"> |
| 29 | <SimpleCodeBlock className="python" parentClassName="min-h-72"> |
| 30 | {` |
| 31 | import os |
| 32 | from flask import Flask |
| 33 | from briven import create_client, Client |
| 34 | from dotenv import load_dotenv |
| 35 | |
| 36 | load_dotenv() |
| 37 | |
| 38 | app = Flask(__name__) |
| 39 | |
| 40 | briven: Client = create_client( |
| 41 | os.environ.get("BRIVEN_URL"), |
| 42 | os.environ.get("BRIVEN_KEY") |
| 43 | ) |
| 44 | |
| 45 | @app.route('/') |
| 46 | def index(): |
| 47 | response = briven.table('todos').select("*").execute() |
| 48 | todos = response.data |
| 49 | |
| 50 | html = '<h1>Todos</h1><ul>' |
| 51 | for todo in todos: |
| 52 | html += f'<li>{todo["name"]}</li>' |
| 53 | html += '</ul>' |
| 54 | |
| 55 | return html |
| 56 | |
| 57 | if __name__ == '__main__': |
| 58 | app.run(debug=True) |
| 59 | `} |
| 60 | </SimpleCodeBlock> |
| 61 | </ConnectTabContent> |
| 62 | </ConnectTabs> |
| 63 | ) |
| 64 | } |
| 65 | |
| 66 | export default ContentFile |