Add app.py as pack host
This commit is contained in:
parent
fe92f62d3f
commit
ac8f86791c
2 changed files with 28 additions and 0 deletions
27
app.py
Normal file
27
app.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from flask import Flask, send_from_directory, abort
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/file/<name>")
|
||||||
|
def get_file(name):
|
||||||
|
if not os.path.exists("/scripts/files/" + name):
|
||||||
|
abort(404)
|
||||||
|
return send_from_directory("/scripts/files", name)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
port = 8080
|
||||||
|
config_file = Path(__file__).parent / "config.properties"
|
||||||
|
if config_file.exists():
|
||||||
|
lines = config_file.read_text().splitlines()
|
||||||
|
for line in lines:
|
||||||
|
if "=" not in line: continue
|
||||||
|
key, value = line.split("=", 1)
|
||||||
|
if key == "port":
|
||||||
|
port = int(value)
|
||||||
|
|
||||||
|
app.run(host='0.0.0.0', port=port)
|
1
config.properties
Normal file
1
config.properties
Normal file
|
@ -0,0 +1 @@
|
||||||
|
port=25566
|
Loading…
Reference in a new issue