-
Notifications
You must be signed in to change notification settings - Fork 32
Added new method #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| from asyncio import subprocess | ||
| from flask import Flask, request, jsonify, send_file, send_from_directory | ||
| from werkzeug.utils import secure_filename | ||
| import os | ||
| from subprocess import call | ||
| from subprocess import call, run, Popen | ||
| from pathlib import Path | ||
|
|
||
|
|
||
|
|
@@ -47,6 +48,59 @@ def upload(dir): | |
| resp.status_code = 500 | ||
| return resp | ||
|
|
||
| @app.route('/build/<dir>', methods=['POST']) | ||
| def build(dir): | ||
| makestudy_dir = "demo" + "/" + dir | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makestduy_dir = dir |
||
| cur_path = os.getcwd() | ||
| concore_path = os.path.abspath(os.path.join(cur_path, '../../')) | ||
| dir_path = os.path.abspath(os.path.join(concore_path, dir)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "dir" here must be replaced by a splitted version to get the "sample" below: |
||
| if not os.path.exists(secure_filename(dir_path)): | ||
| p1 = call(["./makestudy", makestudy_dir], cwd=concore_path) | ||
| if(p1 == 0): | ||
| resp = jsonify({'message': 'Directory successfully created'}) | ||
| resp.status_code = 201 | ||
| return resp | ||
| else: | ||
| resp = jsonify({'message': 'There is an Error'}) | ||
| resp.status_code = 500 | ||
| return resp | ||
| call(["./build"], cwd=dir_path) | ||
| return resp | ||
|
|
||
|
|
||
| @app.route('/debug/<dir>', methods=['POST']) | ||
| def debug(dir): | ||
| cur_path = os.getcwd() | ||
| concore_path = os.path.abspath(os.path.join(cur_path, '../../')) | ||
| dir_path = os.path.abspath(os.path.join(concore_path, dir)) | ||
| p1 = call(["./debug"], cwd=dir_path) | ||
| if(p1 == 0): | ||
| resp = jsonify({'message': 'Close the pop window after obtaing result'}) | ||
| resp.status_code = 201 | ||
| return resp | ||
| else: | ||
| resp = jsonify({'message': 'There is an Error'}) | ||
| resp.status_code = 500 | ||
| return resp | ||
|
|
||
|
|
||
|
|
||
| @app.route('/destroy/<dir>', methods=['POST']) | ||
| def destroy(dir): | ||
| cur_path = os.getcwd() | ||
| concore_path = os.path.abspath(os.path.join(cur_path, '../../')) | ||
| p1 = call(["./destroy", dir], cwd=concore_path) | ||
| if(p1 == 0): | ||
| resp = jsonify({'message': 'Successfuly deleted Dirctory'}) | ||
| resp.status_code = 201 | ||
| return resp | ||
| else: | ||
| resp = jsonify({'message': 'There is an Error'}) | ||
| resp.status_code = 500 | ||
| return resp | ||
|
|
||
|
|
||
|
|
||
| # To execute any python file. For example, /execute/test?apikey=xyz | ||
| @app.route('/execute/<dir>', methods=['POST']) | ||
| def execute(dir): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dir should be the whole input as in "demo/sample" rather than hard-coding "demo" below.