Forums

API Request to run Code on Flask

Hello I'm new to python and I wanted to run code on the flask but my Bot can't access the API and I think it's cause my url is wrong the my host name and username is Both Mistik so yeah I tried this

https://Mistik.pythonanywhere.com//api/v0/user/Mistik To run the code but that doesn't seem to help I looked around but sadly couldn't find anything

We need more details to help you -- is this the API you set up, or are you trying to hit our API?

I made a Web app and I'm trying to connect to it via a api request I made a flask that should run code when it gets an api request send with headers

But I don't get any response

https://Mistik.pythonanywhere.com//api/v0/user/Mistik it looks like you ave two slashes in your url. Should it be https://Mistik.pythonanywhere.com/api/v0/user/Mistik?

Hey I'm still getting the 405 code "Not found"

::: <!doctype html> <html lang=en> <title>404 Not Found</title> <h1>Not Found</h1> <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p> :::

Just so you know I did not install or code anything to make an API if that's something you nerd todo extra I just made a flask that runs code correctly I think idk if that's something bad or not there

If you want you Flask site to do anything when it receives requests on a particular URL, you'll need to write a view function to handle it, with an @route decorator to specify which URL it's on.

I have something like this in the flask

@app.route('/', methods=['POST'])

That's in my code located is that what you meant?

So that would handle a request to the root page "mistik.pythonanywhere.com/", if you want to support other paths, you need to add more routing, see the docs.