Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 17 days ago.
Improve this question
I'm wondering if you can use f strings within a path in fastapi. For example, I want to do the following:
common_path = '/{user}/{item_id}'
#app.get(f'{common_path}/testing')
would this work?
Yes it's work as intended!
from fastapi import FastAPI
app = FastAPI()
common_path = '/{user}/{item_id}'
#app.get(f'{common_path}/testing')
def read_commom_path(user: int, item_id: int):
return {"user": user, "item_id": item_id}
And running uvicorn as uvicorn fastApiTest:app --reload --host localhost --port 1999
And below is the result from testing using Postman
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 days ago.
Improve this question
I use this library: https://github.com/yusufusta/ytstudio
When you are uploading video, to interact with youtube api you need to have SESSION_TOKEN
I checked documentation and i have seen that i need to make request to studio.youtube.com and get response of /grst endpoint.
Can i get SESSION_TOKEN without entering to youtube studio in python automatically?
I tried to send request to /grst but i couldn't do it.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 11 months ago.
Improve this question
I had a requirement of migrating twisted to FastApi.
The old code was completely written in Python 2.7 and used JsonPrc along with twisted client.
Like - [https://stackoverflow.com/a/4738563][1]
Even the static content like html,css,js files used jsonprc to access the API calls. Like there is a complete index.html file which has dependency on html,css, js with jsonprc calls.
I have gone through some documents but couldn't come to conclusion.
Below were few links-
https://github.com/smagafurov/fastapi-jsonrpc
https://github.com/authorizon/fastapi_websocket_rpc
In these I cant see how to integrate html,css,js with jsonrpc. for eg., index.html
So I just want to know the approach to achieve my requirement.
Like websocket, jsonrpc or jinja Template ? Thanks
Is your main issue to serve static files? FastApi has an easy dedicated solution for that: https://fastapi.tiangolo.com/tutorial/static-files/
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I started learning django and just deployed my first app when this showed up.
Any suggestions would be useful.
(https://i.stack.imgur.com/GgMjG.png)
it should be
from django.conf.urls import url
(without s at the end)
There is an error in your import, it should be:
from django.conf.urls import url
ref:https://docs.djangoproject.com/en/1.11/ref/urls/
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
When I route back to index with a parameter eg app.route('/index?status=<status>'), why is the URL escaped on the browser side?
http://127.0.0.1:5000/index%3Fstatus%3Dfalse
Or, more towards my question, how do I unescape the URL? And where in Flask am I able to do this? I did some googling around Flask and Werkzeug, but wasn't able to find anything...
Don't put the query string in the route. Instead, use request.args.get to access them.
#app.route('/index')
if 'status' in request.args:
status = request.args.get('status')
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a l̶i̶s̶t̶ string in Python
[Volume:vol-XXXXXXXX, Volume:vol-YYYYYYYY]
that I want to change to into JSON. The final result should be
{ volumes: ["Volume:vol-XXXXXXXX", "Volume:vol-YYYYYYYY"] };
I tried using json.dumps after changing it to a dict but for some reason it didn't work. How do I do something like this?
WHOOPS! The "list" I was talking about was actually a string :|. Guess I learned my lesson with a downvote storm!
Try this:
volumes = ["Volume:vol-XXXXXXXX", "Volume:vol-YYYYYYYY"]
json.dumps({
"volumes": volumes
})