32 lines
846 B
Python
32 lines
846 B
Python
from flask import render_template, jsonify
|
|
from modules.db import db, User
|
|
from modules.app import app
|
|
from dotenv import load_dotenv
|
|
import os
|
|
import modules.steam_api as api
|
|
|
|
load_dotenv()
|
|
|
|
app.config['STEAM_API_KEY'] = os.getenv('STEAM_API_KEY')
|
|
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv("DATABASE_URL")
|
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
|
app.config['DEBUG'] = os.getenv('DEBUG')
|
|
|
|
with app.app_context():
|
|
db.init_app(app)
|
|
db.create_all() # Create tables
|
|
|
|
@app.route("/")
|
|
def hello():
|
|
return render_template("main.html.jinja")
|
|
|
|
@app.route("/user/<steam_id>")
|
|
def user_route(steam_id):
|
|
user = api.get_user(steam_id)
|
|
if not user:
|
|
return jsonify({"error": "User not found"}), 404
|
|
return jsonify(user.to_dict())
|
|
|
|
if __name__ == "__main__":
|
|
app.run(host="0.0.0.0", port=80, debug=True)
|