Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion .env

This file was deleted.

17 changes: 4 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
FROM python:3.10

EXPOSE 80
EXPOSE 443
EXPOSE 8080
EXPOSE 8000

RUN mkdir static
RUN mkdir templates
ADD app.py .
ADD bak .
ADD db.py .
ADD db.sqlite .
ADD nmap.xsl .
ADD Pipfile .
ADD Procfile .
ADD auth_keys.db .
ADD requirements.txt .
ADD test.py .
ADD README.md .
ADD wsgi.py .
ADD nmapapi.service .
COPY static /static/
COPY templates /templates/

RUN apt update && apt upgrade -y
RUN apt install nmap -y
RUN pip install -r requirements.txt

ENV OPENAI_API_KEY=''

CMD [ "sh", "-c","python ./app.py ${OPENAI_API_KEY}" ]
ENTRYPOINT [ "gunicorn", "-w", "4", "-b", "0.0.0.0:443", "--timeout", "2400", "--max-requests", "0", "wsgi:app" ]
26 changes: 26 additions & 0 deletions Dockerfile.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM python:3.10

EXPOSE 80
EXPOSE 443
EXPOSE 8080
EXPOSE 8000

ENV API_KEY='OPENAI_API_KEY'

RUN mkdir static
RUN mkdir templates
ADD app.py .
ADD auth_keys.db .
ADD requirements.txt .
ADD .env .
ADD README.md .
COPY static /static/
COPY templates /templates/

RUN apt update && apt upgrade -y
RUN apt install nmap -y
RUN pip install -r requirements.txt

RUN echo "API_KEY = '${API_KEY}'" >> .env

CMD [ "sh", "-c","python ./app.py" ]
8 changes: 1 addition & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import nmap
import openai

from dotenv import load_dotenv
from flask import Flask
from flask import render_template
from flask_restful import Api
from flask_restful import Resource

load_dotenv()
openai.api_key = os.getenv('API_KEY')
openai.api_key = '__API__KEY__'
model_engine = "text-davinci-003"

app = Flask(__name__)
Expand Down Expand Up @@ -277,7 +275,3 @@ def get(self, auth, url):
p4, "/api/p4/<string:auth>/<string:url>")
api.add_resource(
p5, "/api/p5/<string:auth>/<string:url>")


if __name__ == '__main__':
app.run(host="0.0.0.0", port="80")
12 changes: 12 additions & 0 deletions nmapapi.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Nmap API deployment
After=network.target

[Service]
User=root
WorkingDirectory=/
ExecStart=/usr/local/bin/gunicorn -w 4 wsgi:app
Restart=always

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion package/nmap_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ def get(self, url):


def start_api():
app.run(host="0.0.0.0", port="80")
app.run(host="0.0.0.0", port="443")
Binary file modified requirements.txt
Binary file not shown.
4 changes: 4 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from app import app

if __name__ == "__main__":
app.run()