Forums

Web app URL not found!

Hi guys,

Can anyone help me to resolve below issue:

"Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."

I have update app.py file under home/tsis/mysite with below code:

@app.route('/') def index(): return 'This is your front page'

My Full code :

from flask import Flask, request from flask_restful import Resource, Api from json import dumps from flask import jsonify from flask_cors import CORS from connection.ConnectWoocommerce import connect_woocommerce from filter_order_data import get_order_data from filter_order_data import get_vendor_metadata from filter_order_data import fetch_vendor_data from latest_orders import get_latest_orders from SheetOperations import update_tracking_data, update_note from connection.GoogleSheetAuthorization import connect import ast import json

modify this variable based on the current environment

valid values = test, prod

Valid values - test / prod

env = "prod"

if env == "test": config_file_path = "" else: config_file_path = r"/home/tsis/mysite/"

with open('{}config.json'.format(config_file_path)) as main_config: config_data = json.load(main_config) app_config = config_data[env]

app = Flask(name) CORS(app) api = Api(app)

class Invoice(Resource): def get(self, vendor_id): order_consolidated_data = list() tsis_commission_gst = float(app_config["tsis_commission_gst"]) vendor_data = fetch_vendor_data(app_config["vendor_json_loc"]) order_data = get_order_data(int(vendor_id), vendor_data, app_config["output_json_loc"]) invoice_data = get_vendor_metadata(int(vendor_id), vendor_data)

    commission_list = [float(data[7]) for data in order_data]
    payment_list = [float(data[9]) for data in order_data]

    temp_pre_gst_comm = sum(commission_list)*100/(100 + float(tsis_commission_gst))
    temp_pre_gst_comm = float("{0:.2f}".format(temp_pre_gst_comm))

    order_consolidated_data.append(temp_pre_gst_comm)
    order_consolidated_data.append(float("{0:.2f}".format(sum(commission_list) - temp_pre_gst_comm)))
    order_consolidated_data.append(float("{0:.2f}".format(sum(commission_list))))
    order_consolidated_data.append(float("{0:.2f}".format(sum(payment_list))))

    return {'invoice_data': invoice_data,
    'order_data': order_data,
    'consolidated_data': order_consolidated_data}

class Login(Resource): def get(self, credentials): # Here credentials is a list containing username and password credentials = ast.literal_eval(credentials) vendor_data = fetch_vendor_data(app_config["vendor_json_loc"]) vendor_id = None for vendor in vendor_data: if vendor["email"] == credentials[0] and vendor["password"] == credentials[1]: vendor_id = vendor["vendor_id"] return vendor_id

class Orders(Resource): def get(self, vendor_id): # Get the latest orders of the current vendor vendor_data = fetch_vendor_data(app_config["vendor_json_loc"]) current_vendor_data = get_vendor_metadata(vendor_id, vendor_data) order_data, courier_name_list = get_latest_orders(current_vendor_data) return {"order_data": order_data, "courier_name_list": courier_name_list}

class Tracking(Resource): def get(self, order_id, product_name, courier_name, tracking_id): # Connect to the Courier tracking Sheet sheet = connect("Production") tracking_updated = update_tracking_data(sheet, order_id, product_name, courier_name, tracking_id) return tracking_updated

class OrderNotes(Resource): def post(self): # Add custom note to the tracking sheet sheet = connect("Production") request_json = request.get_json() note_updated = update_note(sheet, request_json["order_id"], request_json["product_name"], request_json["note_text"]) return note_updated

api.add_resource(Invoice, '/invoice/<vendor_id>') # Route_1 api.add_resource(Login, '/login/<credentials>') # Route_2 api.add_resource(Orders, '/orders/<vendor_id>') api.add_resource(Tracking, '/orders/update_tracking/<order_id>/<product_name>/<courier_name>/<tracking_id>') api.add_resource(OrderNotes, '/orders/add_note/')

@app.route('/') def index(): return 'This is your front page'

if name == 'main': app.run()

I am a beginner. please update me where should I correct the view to make my web app url works.

Thanks!

Your web app appears to be showing the expected front page at the moment.

Its returning "This is your front page" if I access http://tsis.pythonanywhere.com/ but I want to see my web config page to make the configuration.

Please guide.

Thanks!

Your app.route for "/" returns 'This is your front page', so that is what is shown on the page. If you want the "/" route to return a config page, then you should modify that function to return the config page that you want to publish on "/"

please let me know the example code of that or please modify the above code.

I don't see any code that is obviously for configuring your web app in the code you posted. So I don't know what that would be.