FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important
information on the platform change.
01-03-2024 02:02 PM
Hello people,
I hope communication is the correct topic for this question.
Situation: I am currently working on a camera app. The app may get a GUI provided via package-www over snap-craft, which still requires a back-end. Due to bandwidth constraints these the images are currently provided over HTTP in binary form.
What is the best/desired practice for this?
What library would you advise to use to host the HTTP server?
Should the URL be provided in the datalayer?
What would be the/your preferred format for images?
Solved! Go to Solution.
01-03-2024 03:03 PM
Hi @seinsiedler ,
I'm not sure anyone is going to be able to provide best practices on this specific application. A lot of your questions are really user preference.
I can share my own experience on this topic though.
Please let me know if you have any other questions! An example Flask server implementation is below.
from xml.etree.ElementTree import tostring
from flask import Flask
from flask_cors import CORS
import os
app = Flask(__name__,
static_url_path='',
static_folder='Resources/')
CORS(app)
dir_path = 'Resources/'
@app.route('/directories')
def directories():
dirs = []
try:
for path in os.scandir(dir_path):
if path.is_dir():
print(path.name)
dirs.append(str(path.name))
return dirs
except Exception as e:
print(e)
@app.route('/fileCount/<target>/<folder>')
def fileCount(target = None, folder = None):
print(dir_path + target +'/' + folder)
count = 0
try:
for path in os.scandir(dir_path + target +'/' + folder):
if path.is_file():
count += 1
return str(count)
except Exception as e:
print(e)
app.run(host="0.0.0.0")