Ask coding questions

← Back to all posts
Flask getting input with GET
[deleted]

I cant get Requests to work. I've tried several variations of this program and all of them show errors. This one shows
"Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application." Any help will be greatly appreciated.

Answered by Saml2020 [earned 5 cycles]
View Answer
Voters
maxina
CrafttheWorld
Comments
hotnewtop
Saml2020

First of all, forms should submit with the method of POST, as that is more secure and has less limitations. As you are trying to visit the site using GET, you should return index.html in that area.

I edited it.

In main.py

In templates/index.html

ch1ck3n

@Saml2020

First of all, forms should submit with the method of POST

only use post when the form is carrying sensitive information such as passwords or emails

[deleted]

@Saml2020 When I tried POST but it got a "405 Method Not Allowed" error and the work around seemed to be to switch to GET. Btw the link in your comment doesn't seem to work.

CrafttheWorld

@Saml2020 When I clicked on the link didn't work, but when I copied the link and pasted it on a different tab it said "404
Not found error: This is not the page you're looking for.
If you think this is a mistake please contact us_"
Mabey you should try it from your end and see if it works.

Saml2020

@Toadster @CrafttheWorld Fixed the link, should work now.

ruiwenge2

You were following my tutorial right? sorry I think I made a little mistake

do this instead

in main.py:

In index.html:

[deleted]

@ruiwenge2 It complies but it doesn't seem to be returning anything

ruiwenge2

@Toadster change the index.html file to what I wrote

CrafttheWorld

When I ran the code the output said something about a package. Then it said "* Serving Flask app 'app' (lazy loading)

  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: off
  • Running on all addresses.
    WARNING: This is a development server. Do not use it in a production deployment.
  • Running on http://172.18.0.245:8080/ (Press CTRL+C to quit)"
    When I hit CTRL+C it quit. Did it do the same to you?
CosmicBear

@CrafttheWorld it's supposed to do that