I am developing a web page using jinja2 template and alsk framework .
My folder architecture is as follow
Web
|-->static
|-->css
|-->js
|-->img
|-->templates
|-->test1
|-->alaram1.html
|-->test2
|-->alarm2.html
|-->modfunctions
|-->test1
|-->main.py
|-->test2
|-->main.py
I have separate main.py inside test1 and test2 folders. As of now, i'm getting inside 'modfunctions->test1' folder , running python script and getting my output on '0.0.0.0:5000/test1' . Similarly, when I get into 'modfunctions->test2', run main.py. I am getting my output on '0.0.0.0:5000/test2'in browser.
But I want a single .py script using which I can run both test1 and test2 modules same time
here I have my main.py script
from flask import render_template, request, redirect
from flask import Flask
from flask import render_template, request, redirect
app = Flask(__name__, template_folder='/home/web/templates', static_folder='/home/web/static')
@app.route('/test1', methods=['GET','POST'])
def test1():
if request.method == 'GET':
return render_template('test1/alarm1.html')
if request.method == 'POST':
return render_template('test1/alarm1.html')
if __name__ == "__main__":
app.debug = True
app.run(host='0.0.0.0', port=5000)
similarly for test2-main.py
from flask import render_template, request, redirect
from flask import Flask
from flask import render_template, request, redirect
app = Flask(__name__, template_folder='/home/web/templates', static_folder='/home/web/static')
@app.route('/test2', methods=['GET','POST'])
def test2():
if request.method == 'GET':
return render_template('test2/alarm2.html')
if request.method == 'POST':
return render_template('test2/alarm2.html')
if __name__ == "__main__":
app.debug = True
app.run(host='0.0.0.0', port=5000)
Please share some solution