-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added docker config and initial front end components.
- Loading branch information
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM alpine:latest | ||
|
||
RUN apk update && apk upgrade | ||
|
||
RUN apk add jq | ||
RUN apk add pandoc | ||
|
||
RUN apk add --no-cache build-base bash git curl wget python3 python3-dev py3-pip \ | ||
ruby ruby-dev ruby-irb ruby-rdoc ruby-json ruby-bigdecimal | ||
|
||
# Install Rust | ||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
ENV PATH="/root/.cargo/bin:${PATH}" | ||
|
||
# Install Fluent CLI | ||
RUN cargo install --git https://github.com/njfio/fluent_cli fluent | ||
|
||
RUN cargo install --git https://github.com/fpco/amber amber | ||
|
||
RUN pip install flask | ||
|
||
COPY ./frontend /app/frontend | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["flask", "run", "--host=0.0.0.0"] | ||
|
||
RUN mkdir /.fluent/ | ||
RUN cp ~/.cargo/git/checkouts/fluent_cli-*/*/default_config_test.json /.fluent/ | ||
RUN cp ~/.cargo/git/checkouts/fluent_cli-*/*/fluent_autocomplete.sh /.fluent/ | ||
RUN cp ~/.cargo/git/checkouts/fluent_cli-*/*/amber.yaml /.fluent/ | ||
|
||
# Set up Entrypoint | ||
ENTRYPOINT ["bash"] | ||
RUN echo "source /.fluent/fluent_autocomplete.sh" >> ~/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
AMBER_SECRET= | ||
AMBER_YAML=/.fluent/amber.yaml | ||
FLUENT_CLI_V2_CONFIG_PATH=/.fluent/default_config_test.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Fluent Web Frontend</title> | ||
<script> | ||
function executeCommand() { | ||
const command = document.getElementById('command').value; | ||
fetch('/execute', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ command: command }) | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
if (data.output) { | ||
document.getElementById('output').innerText = data.output; | ||
} else if (data.error) { | ||
document.getElementById('output').innerText = "Error: " + data.error; | ||
} | ||
}); | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<h1>Fluent Web Frontend</h1> | ||
<input type="text" id="command" placeholder="Enter Fluent command"> | ||
<button onclick="executeCommand()">Execute</button> | ||
<div id="output"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from flask import Flask, request, jsonify | ||
import subprocess | ||
|
||
app = Flask(__name__, static_url_path='', static_folder='frontend') | ||
|
||
@app.route('/', methods=['GET']) | ||
def index(): | ||
return app.send_static_file('front_end_index.html') | ||
|
||
@app.route('/execute', methods=['POST']) | ||
def execute_fluent(): | ||
command = request.json['command'] | ||
try: | ||
output = subprocess.check_output(["fluent", command], shell=True).decode('utf-8') | ||
return jsonify({'output': output}) | ||
except subprocess.CalledProcessError as e: | ||
return jsonify({'error': str(e)}) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True, host='0.0.0.0') |