24 lines
612 B
Python
24 lines
612 B
Python
|
import os
|
||
|
from flask import jsonify
|
||
|
from sqlalchemy import inspect
|
||
|
|
||
|
|
||
|
def register_route(app,db):
|
||
|
@app.route("/")
|
||
|
def hello_world():
|
||
|
return "<p>Hello, World!</p>"
|
||
|
|
||
|
@app.route('/user/')
|
||
|
@app.route('/user/<username>')
|
||
|
def show_user_profile(username=None):
|
||
|
test = os.getenv("MY_KEY")
|
||
|
if username:
|
||
|
return f"<p>Hello, Mr {username}! You are the man.</p> {test}"
|
||
|
return "<p>Hello, user!</p>"
|
||
|
|
||
|
@app.route('/table')
|
||
|
def list_table():
|
||
|
inspector = inspect(db.engine)
|
||
|
tables = inspector.get_table_names()
|
||
|
return jsonify(tables)
|