server.py 1023 Bytes
import cx_Oracle
import os
from flask import Flask, render_template, request, send_from_directory

from router.update import update
from router.search import search

root_dir = os.path.dirname(os.getcwd())
my_path = os.path.join(root_dir, 'check-your-instagram', 'app', 'public')
app = Flask(__name__, static_folder=os.path.abspath(my_path))

os.putenv('NLS_LANG', '.UTF8')
cx_Oracle.init_oracle_client(lib_dir="/Users/choewonseog/Downloads/instantclient_19_8")


@app.errorhandler(404)
def page_not_found():
    return render_template('404.html')


@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def home(path):
    insta_id = request.args.get('insta_id')
    if path == 'update':
        return update(insta_id)
    elif path == 'search':
        return search(insta_id)
    else:
        return send_from_directory(my_path, filename='index.html')


if __name__ == "__main__":
    print("-" * 60)
    print("  server is start")
    print("-" * 60)

    app.run(host="localhost", port=5000, debug=True)