1seok2

resolve problem of path

......@@ -14,13 +14,10 @@
"lint": "gts lint",
"clean": "gts clean",
"fix": "gts fix",
"prepare": "npm.cmd run compile",
"pretest": "npm.cmd run compile",
"posttest": "npm.cmd run lint",
"compile": "tsc -w",
"build": "webpack --watch",
"start": "webpack serve --open",
"predeploy" : "webpack"
"predeploy": "webpack"
},
"devDependencies": {
"@types/node": "^14.11.2",
......
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/" />
<meta charset="UTF-8">
<title>home</title>
</head>
<body>
<div id="App"></div>
<div id="App"> </div>
<!-- <script src="public/main.js" ></script>-->
</body>
</html>
\ No newline at end of file
......
......@@ -5,7 +5,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode : 'development',
entry : {
// main : './build/src/index.js'
main : './src/index.ts'
},
module : {
......@@ -23,7 +22,8 @@ module.exports = {
test: /\.(png|jpe?g|gif|jp2|webp)$/,
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
name: 'images/[name].[ext]',
publicPath: 'public/'
},
}
]
......@@ -32,8 +32,8 @@ module.exports = {
extensions: [".tsx", ".ts", ".js"],
},
output : {
publicPath: '/app/public',
path: path.resolve('./public'),
publicPath: '/public/',
path: path.resolve('./public/'),
filename: '[name].js',
},
devServer : {
......@@ -46,7 +46,7 @@ module.exports = {
}
},
plugins : [
new CleanWebpackPlugin(),
// new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
template : './src/index.html'
})
......
......@@ -2,12 +2,8 @@ import os
from flask import Flask, render_template, request, jsonify, send_from_directory
from crawler.crawler_instagram import crawler_instagram
app = Flask(__name__)
@app.errorhandler(404)
def page_not_found():
return render_template('404.html')
my_path = '/Users/choewonseog/Documents/check-your-instagram/app/public'
app = Flask(__name__, static_folder=os.path.abspath(my_path))
def update(insta_id):
crawler_instagram(insta_id)
......@@ -18,16 +14,28 @@ def update(insta_id):
return jsonify(data)
@app.errorhandler(404)
def page_not_found():
return render_template('404.html')
@app.route("/", defaults={"path": ""})
@app.route("/<path:path>")
def home(path):
# return render_template('index.html')
print("hi? your in '%s' !!"%(path))
# if path != "" and os.path.exists(app.static_folder + '/' + path):
# return send_from_directory(app.static_folder, path)
# else:
# return send_from_directory(app.static_folder, 'index.html')
if path == 'update':
insta_id = request.args.get('insta_id')
update(insta_id)
else :
return send_from_directory('./app/public/', 'index.html')
elif path == '' :
root_dir = os.path.dirname(os.getcwd())
return send_from_directory(os.path.join(root_dir, 'check-your-instagram', 'app', 'public'), filename='index.html')
return render_template('index.html')
# else:
# return render_template('index.html')
if __name__ == "__main__":
print("-" * 60)
......