main.py import socket from flask import Flask, request, rendertemplate from…
- User
main.py import socket from flask import Flask, request, render_template from werkzeug.exceptions import HTTPException app = Flask(name) def is_port_open(ip, port): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.settimeout(5) try: sock.connect((ip, port)) return True except socket.error: return False finally: sock.close() @app.route('/', methods=['GET', 'POST']) def index(): result = None ip = "" port = "" if request.method == 'POST': ip = request.form.get('ip') port = request.form.get('port') try: port = int(port) if 0 < port < 65536: # Port number should be between 1 and 65535 result = is_port_open(ip, port) else: result = "Invalid port number." except ValueError: result = "Invalid IP address or port number." except Exception as e: result = f"An error occurred: {str(e)}" return render_template('index.html', result=result, ip=ip, port=port) @app.errorhandler(Exception) def handle_exception(e): # pass through HTTP errors if isinstance(e, HTTPException): return e # now you're handling non-HTTP exceptions only return render_template("500_generic.html", e=e), 500 if name == "main": app.run(debug=False) requirements.txt Flask==3.0.0 Werkzeug==3.0.1 vercel.json { "version": 2, "builds": [ { "src": "./main.py", "use": "@vercel/python" } ], "routes": [ { "src": "/(.*)", "dest": "./main.py" } ] }
on deploying to vercel i get 404: NOT_FOUND Code: NOT_FOUND ID: bom1::gnnn8-1710486615088-341f246dde16
deployment logs: Running build in Washington, D.C., USA (East) – iad1 Cloning github.com/SiddheshDongare/AmIVisible (Branch: main, Commit: 6b6988b) Cloning completed: 330.58ms Previous build cache not available Running "vercel build" Vercel CLI 33.5.5 WARN! Due to
buildsexisting in your configuration file, the Build and Development Settings defined in your Project Settings will not apply. Learn More: https://vercel.link/unused-build-settings Installing required dependencies... Build Completed in /vercel/output [3s] Deploying outputs... Deployment completed Uploading build cache [29.00 B]... Build cache uploaded: 362.291ms - Assistant