fix: make it work
This commit is contained in:
parent
a21ba6b8fb
commit
0e43bea656
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
8
.idea/laser-app.iml
Normal file
8
.idea/laser-app.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
7
.idea/misc.xml
Normal file
7
.idea/misc.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7" project-jdk-type="Python SDK" />
|
||||||
|
<component name="PyCharmProfessionalAdvertiser">
|
||||||
|
<option name="shown" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/laser-app.iml" filepath="$PROJECT_DIR$/.idea/laser-app.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
16
Dockerfile
16
Dockerfile
@ -1,29 +1,29 @@
|
|||||||
FROM python:3.8-slim
|
FROM python:3.8-slim
|
||||||
LABEL name=laser-app version=0.1
|
LABEL name=laser-app version=0.1
|
||||||
|
|
||||||
WORKDIR /opt
|
|
||||||
RUN apt update
|
RUN apt update
|
||||||
RUN apt install -y --no-install-recommends build-essential\
|
RUN apt install -y --no-install-recommends build-essential\
|
||||||
gcc\
|
gcc\
|
||||||
libagg2-dev\
|
libagg2-dev\
|
||||||
libpotrace-dev\
|
libpotrace-dev\
|
||||||
nginx-light\
|
|
||||||
pkg-config\
|
pkg-config\
|
||||||
python-dev\
|
python-dev
|
||||||
redis-server
|
|
||||||
RUN rm -f /etc/nginx/sites-enabled/*
|
RUN rm -f /etc/nginx/sites-enabled/*
|
||||||
RUN pip3 install flask numpy pillow redis
|
RUN pip3 install flask numpy pillow redis
|
||||||
RUN pip3 install pypotrace
|
RUN pip3 install pypotrace
|
||||||
|
|
||||||
COPY ./server/files/nginx/sites-enabled/site.conf /etc/nginx/sites-enabled
|
COPY ./server/files/nginx/sites-enabled/site.conf /etc/nginx/sites-enabled
|
||||||
|
|
||||||
|
WORKDIR /opt
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
COPY ./server/entrypoint.sh /usr/bin/
|
# COPY ./server/entrypoint.sh /usr/bin/
|
||||||
RUN chmod +x /usr/bin/entrypoint.sh
|
# RUN chmod +x /usr/bin/entrypoint.sh
|
||||||
|
#
|
||||||
|
# ENTRYPOINT /usr/bin/entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 80
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
EXPOSE 9001
|
|
||||||
|
|
||||||
# Start the main process.
|
# Start the main process.
|
||||||
CMD ["python", "./server.py", "-i", "db"]
|
CMD ["python", "./server.py", "-i", "db"]
|
||||||
|
49
docker-compose.yml
Normal file
49
docker-compose.yml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
version: "3.7"
|
||||||
|
services:
|
||||||
|
nginx:
|
||||||
|
image: nginx:latest
|
||||||
|
ports:
|
||||||
|
- 80:80
|
||||||
|
expose:
|
||||||
|
- 80:80
|
||||||
|
networks:
|
||||||
|
- snap_net
|
||||||
|
volumes:
|
||||||
|
- .:/opt:ro
|
||||||
|
- ./server/files/nginx/sites-enabled/site.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
# command: sleep 60000
|
||||||
|
|
||||||
|
app:
|
||||||
|
image: laserapp:0.1
|
||||||
|
environment:
|
||||||
|
- DB_HOST=redis
|
||||||
|
expose:
|
||||||
|
- 5000
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
|
networks:
|
||||||
|
- snap_net
|
||||||
|
volumes:
|
||||||
|
- ./app/:/app/
|
||||||
|
# command: sleep 60000
|
||||||
|
|
||||||
|
worker:
|
||||||
|
image: laserapp:0.1
|
||||||
|
environment:
|
||||||
|
- DB_HOST=redis
|
||||||
|
networks:
|
||||||
|
- snap_net
|
||||||
|
volumes:
|
||||||
|
- ./app/:/app/
|
||||||
|
command: bash -c "while true; do /usr/local/bin/python3 worker.py; sleep 1; done"
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis
|
||||||
|
networks:
|
||||||
|
- snap_net
|
||||||
|
ports:
|
||||||
|
- 6379
|
||||||
|
|
||||||
|
networks:
|
||||||
|
snap_net:
|
||||||
|
driver: bridge
|
29
js/main.js
29
js/main.js
@ -106,36 +106,15 @@ $(document).ready(function(){
|
|||||||
img = new Image();
|
img = new Image();
|
||||||
var objectUrl = _URL.createObjectURL(file);
|
var objectUrl = _URL.createObjectURL(file);
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
let w = 640
|
let w = 640;
|
||||||
let h = 640 * this.height / this.width
|
let h = 640 * this.height / this.width;
|
||||||
showSnap(this,w,h)
|
showSnap(this,w,h);
|
||||||
};
|
};
|
||||||
img.src = objectUrl;
|
img.src = objectUrl;
|
||||||
}
|
}
|
||||||
if(files && typeof FileReader !== "undefined") {
|
|
||||||
for(var i=0; i<files.length; i++) {
|
|
||||||
// fileToSnap(files[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileToSnap = function(file) {
|
|
||||||
if( (/image/i).test(file.type) ) {
|
|
||||||
var reader = new FileReader();
|
|
||||||
reader.onload = function(e) {
|
|
||||||
let base_image = new Image();
|
|
||||||
base_image.src = e.target.result;
|
|
||||||
console.log(
|
|
||||||
base_image.width
|
|
||||||
)
|
|
||||||
base_image.width = 640;
|
|
||||||
base_image.onload = function(){
|
|
||||||
showSnap(base_image,640,480)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws every segment received, except black colored target ones
|
// Draws every segment received, except black colored target ones
|
||||||
var drawSimu = function() {
|
var drawSimu = function() {
|
||||||
|
17
server.py
17
server.py
@ -22,21 +22,20 @@ m = hashlib.sha256()
|
|||||||
|
|
||||||
# Flask app init
|
# Flask app init
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
#
|
||||||
@app.before_first_request
|
# @app.before_first_request
|
||||||
def setup_logging():
|
# def setup_logging():
|
||||||
if not app.debug:
|
# if not app.debug:
|
||||||
# In production mode, add log handler to sys.stdout.
|
# # In production mode, add log handler to sys.stdout.
|
||||||
app.logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
# app.logger.addHandler(logging.StreamHandler(stream=sys.stdout))
|
||||||
app.logger.setLevel(logging.INFO)
|
# app.logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
# Routing requests
|
# Routing requests
|
||||||
@app.route('/image',methods = ['POST', 'GET'])
|
@app.route('/image',methods = ['POST', 'GET'])
|
||||||
def image():
|
def image():
|
||||||
try:
|
try:
|
||||||
data = dict()
|
data = dict()
|
||||||
|
print("Received request")
|
||||||
res =r.keys("*")
|
|
||||||
# Clean the request
|
# Clean the request
|
||||||
if "text" in request.form:
|
if "text" in request.form:
|
||||||
data["text"] = request.form["text"][:256]
|
data["text"] = request.form["text"][:256]
|
||||||
|
@ -6,6 +6,9 @@ server {
|
|||||||
location ~ /(hash_name|image) {
|
location ~ /(hash_name|image) {
|
||||||
proxy_pass http://app:5000;
|
proxy_pass http://app:5000;
|
||||||
}
|
}
|
||||||
|
location / {
|
||||||
|
try_files $uri /index.html;
|
||||||
|
}
|
||||||
# Docker specific conf
|
# Docker specific conf
|
||||||
resolver 127.0.0.11 ipv6=off;
|
resolver 127.0.0.11 ipv6=off;
|
||||||
access_log /dev/stdout;
|
access_log /dev/stdout;
|
||||||
|
Loading…
Reference in New Issue
Block a user