Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Nested subpath nginx python proxy + spa

22 Sep 2021 »

first proxy

second proxy

python app

from flask import Flask, request, jsonify, json, abort, redirect, url_for, render_template
from flask_cors import CORS, cross_origin
import os
import re
import subprocess
import traceback

app = Flask(__name__, template_folder='template')
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'

@app.route('/', methods=['GET', 'POST'])
@cross_origin()
def main():
    return "hello world"

@app.route('/subpath/python', defaults={'lol': ''}, methods=['GET', 'POST'])
@app.route('/subpath/python/<lol>', methods=['GET', 'POST'])
def r_lol(lol=""):
    return "hello world "+lol

# gunicorn --workers=2 'app:create_app()' --bind=0.0.0.0:<port>
def create_app():
    return app

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8080)
    
    #test 
    #with app.test_client() as c:
    #    rs = c.get("/")
    #    print(rs.data)