Python Forum
How to POST html data to be handled by a route endpoint
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to POST html data to be handled by a route endpoint
#1
Error accessing a route endpoint with same name in 2 processes
Therere 2 different scripts each running on its own process:

www.py is what is running on http://superhost.gr

and test.py is what is running on http://superhost.gr/test

Here is what it contains.
from bottle import Bottle, route, run, debug

application = Bottle()
app = application
debug(True)


@app.route('/mailform', method=['POST'])
def mailform():
	return 'Hello from mailform'


@app.route('/')
def index():
	return '''\
	<form method="post" action="{}">
	<input value="Mail" type="submit" />
	</form>'''.format( app.get_url( '/mailform' ) )
I somehow beleive that the following apache conf directives somehow create problem.
WSGIDaemonProcess test user=nikos group=nikos home=/home/nikos/wsgi
WSGIScriptAlias /test /home/nikos/wsgi/test.py process-group=test application-group=%{GLOBAL}

WSGIDaemonProcess www user=nikos group=nikos home=/home/nikos/wsgi
WSGIScriptAliasMatch / /home/nikos/wsgi/www.py process-group=www application-group=%{GLOBAL}
The only way i can run this is the aforementioned.

IF instead i try to access the endpoint like the following:

@app.route('/')
def index():
	return '''\
	<form method="post" action="/mailform">
	<input value="Mail" type="submit" />
	</form>'''
i receive:

Sorry, the requested URL 'http://superhost.gr/mailform' caused an error:

Quote:Internal Server Error
Exception:
TypeError("argument of type 'NoneType' is not iterable",)
Traceback:
Traceback (most recent call last):
File "/home/nikos/wsgi/bottle.py", line 996, in _handle
out = route.call(**args)
File "/home/nikos/wsgi/bottle.py", line 2007, in wrapper
rv = callback(*a, **ka)
File "/home/nikos/wsgi/www.py", line 189, in mailform
if provider in FROM:
TypeError: argument of type 'NoneType' is not iterable
I somehow beleive that the following apache conf directives somehow create problem.

You will see if you create a route endpoint called '/mailform' within '/' which is an alias of 'www.py' and you also have '/mailform' in 'superhost.gr/test' when the latter tries to post data to '/mailform' instead of sending them to 'superhost.gr/test/' it sends them to '/' which is 'superhost.gr'
Reply
#2
Can someone exaplin please?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 795 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  Post Python to HTML/CSS Extra 3 1,839 Feb-17-2022, 06:07 PM
Last Post: snippsat
  POST Reply to Ajax/jQuery (mostly an HTML question) gw1500se 5 2,606 Nov-18-2021, 02:44 PM
Last Post: gw1500se
  Post HTML Form Data to API Endpoints Dexty 0 1,382 Nov-11-2021, 10:51 PM
Last Post: Dexty
  Zeep - BasicHTTPBinding secured Endpoint throws 500-invalid security error vinoth 0 2,059 Jul-15-2021, 03:00 PM
Last Post: vinoth
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,529 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Cleaning HTML data using Jupyter Notebook jacob1986 7 4,051 Mar-05-2021, 10:44 PM
Last Post: snippsat
  Any way to remove HTML tags from scraped data? (I want text only) SeBz2020uk 1 3,410 Nov-02-2020, 08:12 PM
Last Post: Larz60+
  POST request with form data issue web scraping hoff1022 1 2,649 Aug-14-2020, 10:25 AM
Last Post: kashcode
  concatenate a request to the endpoint of OSM-API?! apollo 0 1,546 Aug-13-2020, 02:45 PM
Last Post: apollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020