Showing
9 changed files
with
107 additions
and
30 deletions
app/src/App.ts
0 → 100644
1 | +/** | ||
2 | + * @author : wonseog | ||
3 | + * @date : 2021/03/08 | ||
4 | + * @description : 메인 app | ||
5 | + * index.ts에서 pathname 받아 | ||
6 | + * 컴포넌트 제작 후 반환 | ||
7 | +**/ | ||
8 | + | ||
9 | +import Header from "./views/header/Header"; | ||
10 | +import Body from "./views/body/Body"; | ||
11 | +import Footer from "./views/footer/Footer"; | ||
12 | + | ||
13 | +const App = (pathname : string) : string => { | ||
14 | + let contents : string = ` | ||
15 | + <div> | ||
16 | + ${Header()} | ||
17 | + hello ${pathname} | ||
18 | + ${Body()} | ||
19 | + ${Footer()} | ||
20 | + </div> | ||
21 | + `; | ||
22 | + | ||
23 | + return contents; | ||
24 | +} | ||
25 | + | ||
26 | +export default App; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
app/src/Bye.ts
deleted
100644 → 0
1 | -export const Bye = () => console.log('Bye!'); |
app/src/components/title.ts
0 → 100644
1 | +/** | ||
2 | + * @author : wonseog | ||
3 | + * @date : 2021/03/08 | ||
4 | + * @description : 타이틀 대 / 중 / 소 반환 | ||
5 | +**/ | ||
6 | + | ||
7 | +const titleTemplate = (type : string, title : string) => ` | ||
8 | + <div class="${type}-title"> | ||
9 | + ${type} ${title} | ||
10 | + </div> | ||
11 | +` | ||
12 | + | ||
13 | +const Title = (title : string) => ({ | ||
14 | + Large : titleTemplate('large', title), | ||
15 | + Medium : titleTemplate('medium', title), | ||
16 | + Small : titleTemplate('small', title) | ||
17 | +}) | ||
18 | + | ||
19 | +export default Title; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
6 | <title>home</title> | 6 | <title>home</title> |
7 | </head> | 7 | </head> |
8 | <body> | 8 | <body> |
9 | - <div id="App"> </div> | 9 | + <div id="App"></div> |
10 | <!-- <script src="public/main.js" ></script>--> | 10 | <!-- <script src="public/main.js" ></script>--> |
11 | </body> | 11 | </body> |
12 | </html> | 12 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -import {Bye} from './Bye'; | ||
2 | -import './assets/style/App.css'; | ||
3 | -import v4 from './assets/image/v4Logo.png'; | ||
4 | - | ||
5 | -const hi = 'hchoi won'; | ||
6 | - | ||
7 | -const hi1 = () => { | ||
8 | - console.log(hi); | ||
9 | - Bye(); | ||
10 | - | ||
11 | - const tag = window.document.querySelector('#App'); | ||
12 | - | ||
13 | - if(tag) { | ||
14 | - tag.innerHTML = `<img src=${v4} alt="image" />`; | ||
15 | - } | ||
16 | -}; | ||
17 | - | ||
18 | -hi1(); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/** | ||
2 | + * @author : wonseog | ||
3 | + * @date : 2021/03/08 | ||
4 | + * @description : 현재 pathname을 파악 후 App으로 전달 | ||
5 | +**/ | ||
6 | +import App from "./App"; | ||
7 | + | ||
8 | +window.addEventListener('DOMContentLoaded', () => { | ||
9 | + const $App = document.querySelector('#App'); | ||
10 | + let pathname = window.location.pathname.split('/')[1]; | ||
11 | + | ||
12 | + $App && ($App.innerHTML = App(pathname)); | ||
13 | +}) | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
app/src/views/body/Body.ts
0 → 100644
app/src/views/footer/Footer.ts
0 → 100644
app/src/views/header/Header.ts
0 → 100644
1 | +/** | ||
2 | + * @author : wonseog | ||
3 | + * @date : 2021/03/08 | ||
4 | + * @description : 페이지 헤더 | ||
5 | +**/ | ||
6 | +import Title from "../../components/title"; | ||
7 | + | ||
8 | +const Header = () : string => { | ||
9 | + | ||
10 | + return ` | ||
11 | + <div class="header">${Title('im title').Large}</div> | ||
12 | + `; | ||
13 | +} | ||
14 | + | ||
15 | +export default Header; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -5,6 +5,7 @@ from crawler.crawler_instagram import crawler_instagram | ... | @@ -5,6 +5,7 @@ from crawler.crawler_instagram import crawler_instagram |
5 | my_path = '/Users/choewonseog/Documents/check-your-instagram/app/public' | 5 | my_path = '/Users/choewonseog/Documents/check-your-instagram/app/public' |
6 | app = Flask(__name__, static_folder=os.path.abspath(my_path)) | 6 | app = Flask(__name__, static_folder=os.path.abspath(my_path)) |
7 | 7 | ||
8 | + | ||
8 | def update(insta_id): | 9 | def update(insta_id): |
9 | crawler_instagram(insta_id) | 10 | crawler_instagram(insta_id) |
10 | 11 | ||
... | @@ -18,24 +19,18 @@ def update(insta_id): | ... | @@ -18,24 +19,18 @@ def update(insta_id): |
18 | def page_not_found(): | 19 | def page_not_found(): |
19 | return render_template('404.html') | 20 | return render_template('404.html') |
20 | 21 | ||
22 | + | ||
21 | @app.route("/", defaults={"path": ""}) | 23 | @app.route("/", defaults={"path": ""}) |
22 | @app.route("/<path:path>") | 24 | @app.route("/<path:path>") |
23 | def home(path): | 25 | def home(path): |
24 | - print("hi? your in '%s' !!"%(path)) | ||
25 | - | ||
26 | - # if path != "" and os.path.exists(app.static_folder + '/' + path): | ||
27 | - # return send_from_directory(app.static_folder, path) | ||
28 | - # else: | ||
29 | - # return send_from_directory(app.static_folder, 'index.html') | ||
30 | if path == 'update': | 26 | if path == 'update': |
31 | insta_id = request.args.get('insta_id') | 27 | insta_id = request.args.get('insta_id') |
32 | update(insta_id) | 28 | update(insta_id) |
33 | - elif path == '' : | 29 | + # elif path == '': |
30 | + else: | ||
34 | root_dir = os.path.dirname(os.getcwd()) | 31 | root_dir = os.path.dirname(os.getcwd()) |
35 | return send_from_directory(os.path.join(root_dir, 'check-your-instagram', 'app', 'public'), filename='index.html') | 32 | return send_from_directory(os.path.join(root_dir, 'check-your-instagram', 'app', 'public'), filename='index.html') |
36 | - return render_template('index.html') | 33 | + |
37 | - # else: | ||
38 | - # return render_template('index.html') | ||
39 | 34 | ||
40 | if __name__ == "__main__": | 35 | if __name__ == "__main__": |
41 | print("-" * 60) | 36 | print("-" * 60) | ... | ... |
-
Please register or login to post a comment