Git Product home page Git Product logo

Comments (12)

linhub15 avatar linhub15 commented on August 22, 2024 2

Let me elaborate on @wujingquan's suggestion, correct me if I'm wrong.
If you want to submit a post request in a browser you need to

  1. Run your code
  2. Create a file called index.html with this content and open it in a browser
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<form action="http://127.0.0.1:8000" method="post">
  <input type="submit" value="Submit">
</form>
</body>
</html>
  1. Click the button

Navigating to http://127.0.0.1:8000 in any browser will only send GET requests and you can't test the POST functionality of your code.

For more on HTTP requests check out MDN - HTTP request methods.

from oak.

wtho avatar wtho commented on August 22, 2024 2

Just to add a small detail to the explanation:
If you put a URL in any browser's URL Bar, it will always run GET against that URL endpoint.
To run POST you need to use a form submit or an ajax call.
Cheers!

from oak.

johnsonsamuel avatar johnsonsamuel commented on August 22, 2024 1

It is throwing error when I run from command line :|

It's OK for me!
image

from oak.

wujingquan avatar wujingquan commented on August 22, 2024 1

What error message ?

from oak.

wujingquan avatar wujingquan commented on August 22, 2024

It's OK for me!
image

from oak.

johnsonsamuel avatar johnsonsamuel commented on August 22, 2024

What error message ?

I get
Screen Shot 2020-02-05 at 8 26 39 AM
HTTP ERROR 405

from oak.

linhub15 avatar linhub15 commented on August 22, 2024

If you use Chrome it defaults to a GET request.
Try using curl -X POST http://127.0.0.1:8000

from oak.

johnsonsamuel avatar johnsonsamuel commented on August 22, 2024

If you use Chrome it defaults to a GET request.
Try using curl -X POST http://127.0.0.1:8000

Oh yeah, it does work with curl but not through browser. Any thoughts ?

from oak.

wujingquan avatar wujingquan commented on August 22, 2024

AJAX or form set method="POST"

from oak.

johnsonsamuel avatar johnsonsamuel commented on August 22, 2024

AJAX or form set method="POST"

The code I have posted is the one I am trying to use.

from oak.

ryhinchey avatar ryhinchey commented on August 22, 2024

I think this issue can be closed πŸ˜„

from oak.

wujingquan avatar wujingquan commented on August 22, 2024

I think this issue can be closed πŸ˜„

+1

from oak.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.