Skip to content
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

web-interface added by flask #19

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from flask import Flask
from flask import render_template
from flask import request,redirect,session
from flask.helpers import url_for
import subprocess

import os

TIMEOUT = 1
MAX_TTL = 50
DEFAULT_OUTPUT_DIR = "./tracevis_data/"

app = Flask(__name__)
app.secret_key = 'the random string'
@app.route('/',methods = ['GET', 'POST'])
def index():

if request.method == 'GET':
name = 'Rosalia'
return render_template('index.html', title='Welcome', username=name)
if request.method == 'POST':

url= request.form.get('url')


return redirect(url_for('process'))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to change this part. Both naming and UI.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @ramtinsafadoust ! ❤️ 🌺

@moh53n, let me know if you would like to work on this and/or continue in a new branch.

i try to fix your correct suggests

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@app.route('/process',methods = ['GET', 'POST'])
def process():
if request.method=="POST":
url= request.form.get('url')
temp_return= run_command('sudo python3 ./tracevis.py --dns --domain1 %s --domain2 %s'% (url, url))
x=str(temp_return).rsplit('/', 1)[-1]
size=len(x)
z=x[:size - 3]
y= 'tracevis_data/'+z
return render_template(y)
#return render_template('proccess.html')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to change this part too.

  1. naming
  2. UI
  3. command. 1) The app should be able to run on Windows too. Therefore we should check for OS name first. 2) The way of using the tracevis command is almost incorrect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i want to make docker file from web interface after fix changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved


def run_command(command):
return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()


app.run(host='0.0.0.0', port=5000)
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
scapy
pyvis
scapy
pyvis
flask
49 changes: 49 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be able to run the app when we do not have internet access.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove bootstrap library

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it is still not possible to work offline.
I will add a patch to this at the end.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resoved


<title>{{ title }}</title>



<script>
document.getElementById('button').onclick = function() {
alert("button was clicked");
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the button should be disabled until the end of the operation or always.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you right

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

</script>



</head>
<body style="text-align: -webkit-center;" >
<h1>TraceVis</h1>
<br>


<div style="align-self: center;" >

<div class="form-group">
<form action="/process" method="POST" style="margin-left: 10%; margin-right: 10%;" >

<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="basic-addon1">URL</span>
</div>
<input type="text" class="form-control" placeholder="https://github.com" aria-label="Username" aria-describedby="basic-addon1" name="url">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to change this line. e.g. placeholder, aria-label, name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its ok

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

</div>
</div>

<button id="button" type="submit" class="btn btn-warning">START</button>
</form>
</div>
<div id="loader">
<div id="shadow"></div>
<div id="box"></div>
</div>
<br>
<h4>This process may take more than 5 minutes - be patient</h4>


</body>
</html>
84 changes: 84 additions & 0 deletions templates/proccess.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<html>
<head><title> proccess </title></head>


<body>

<div id="loader">
<div id="shadow"></div>
<div id="box"></div>
</div>
<h4>Please Wait - Prossessing</h4>


<style>
#loader {
/* Uncomment this to make it run! */
/*
animation: loader 5s linear infinite;
*/

position: absolute;
top: calc(50% - 20px);
left: calc(50% - 20px);
}
@keyframes loader {
0% { left: -100px }
100% { left: 110%; }
}
#box {
width: 50px;
height: 50px;
background: #fff;
animation: animate .5s linear infinite;
position: absolute;
top: 0;
left: 0;
border-radius: 3px;
}
@keyframes animate {
17% { border-bottom-right-radius: 3px; }
25% { transform: translateY(9px) rotate(22.5deg); }
50% {
transform: translateY(18px) scale(1,.9) rotate(45deg) ;
border-bottom-right-radius: 40px;
}
75% { transform: translateY(9px) rotate(67.5deg); }
100% { transform: translateY(0) rotate(90deg); }
}
#shadow {
width: 50px;
height: 5px;
background: #000;
opacity: 0.1;
position: absolute;
top: 59px;
left: 0;
border-radius: 50%;
animation: shadow .5s linear infinite;
}
@keyframes shadow {
50% {
transform: scale(1.2,1);
}
}


body {
background: #6997DB;
overflow: hidden;
}
h4 {
position: absolute;
bottom: 20px;
left: 20px;
margin: 0;
font-weight: 200;
opacity: .5;
font-family: sans-serif;
color: #fff;
}
</style>

</body>
</html>
Loading