Is there a way to get the full url in flask_restful from a resource [duplicate]
up vote
1
down vote
favorite
This question already has an answer here:
Where do I define the domain to be used by url_for() in Flask?
1 answer
How do I get the different parts of a Flask request's url?
3 answers
Say I have a Resource that does not do anything but returns the url to the console
from app import api
class StaticFiles(Resource):
def get(self):
return api.url_for(self) # this only provides the resource url
if the request was http://localhost:5000/static code above returns /static
I am looking for http://localhost:5000/static
Usually I use requests but there is no request in resources.
I am looking for pretty much the equivalent of request.base_url
python rest url flask flask-restful
marked as duplicate by Dušan Maďar, davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 13:46
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
1
down vote
favorite
This question already has an answer here:
Where do I define the domain to be used by url_for() in Flask?
1 answer
How do I get the different parts of a Flask request's url?
3 answers
Say I have a Resource that does not do anything but returns the url to the console
from app import api
class StaticFiles(Resource):
def get(self):
return api.url_for(self) # this only provides the resource url
if the request was http://localhost:5000/static code above returns /static
I am looking for http://localhost:5000/static
Usually I use requests but there is no request in resources.
I am looking for pretty much the equivalent of request.base_url
python rest url flask flask-restful
marked as duplicate by Dušan Maďar, davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 13:46
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
This question already has an answer here:
Where do I define the domain to be used by url_for() in Flask?
1 answer
How do I get the different parts of a Flask request's url?
3 answers
Say I have a Resource that does not do anything but returns the url to the console
from app import api
class StaticFiles(Resource):
def get(self):
return api.url_for(self) # this only provides the resource url
if the request was http://localhost:5000/static code above returns /static
I am looking for http://localhost:5000/static
Usually I use requests but there is no request in resources.
I am looking for pretty much the equivalent of request.base_url
python rest url flask flask-restful
This question already has an answer here:
Where do I define the domain to be used by url_for() in Flask?
1 answer
How do I get the different parts of a Flask request's url?
3 answers
Say I have a Resource that does not do anything but returns the url to the console
from app import api
class StaticFiles(Resource):
def get(self):
return api.url_for(self) # this only provides the resource url
if the request was http://localhost:5000/static code above returns /static
I am looking for http://localhost:5000/static
Usually I use requests but there is no request in resources.
I am looking for pretty much the equivalent of request.base_url
This question already has an answer here:
Where do I define the domain to be used by url_for() in Flask?
1 answer
How do I get the different parts of a Flask request's url?
3 answers
python rest url flask flask-restful
python rest url flask flask-restful
edited Nov 20 at 9:46
Dušan Maďar
4,21241935
4,21241935
asked Nov 20 at 9:15
Evren Bingøl
5581727
5581727
marked as duplicate by Dušan Maďar, davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 13:46
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Dušan Maďar, davidism
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 20 at 13:46
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
request
is a global object which you can access by import
ing request
from flask
:
from flask import request
from app import api
class StaticFiles(Resource):
def get(self):
return(request.base_url)
There are lots of nice alternative formats of the url here, see this answer for more details.
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of therequest
in the first place!
– Rob Bricheno
Nov 20 at 18:27
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
request
is a global object which you can access by import
ing request
from flask
:
from flask import request
from app import api
class StaticFiles(Resource):
def get(self):
return(request.base_url)
There are lots of nice alternative formats of the url here, see this answer for more details.
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of therequest
in the first place!
– Rob Bricheno
Nov 20 at 18:27
add a comment |
up vote
1
down vote
request
is a global object which you can access by import
ing request
from flask
:
from flask import request
from app import api
class StaticFiles(Resource):
def get(self):
return(request.base_url)
There are lots of nice alternative formats of the url here, see this answer for more details.
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of therequest
in the first place!
– Rob Bricheno
Nov 20 at 18:27
add a comment |
up vote
1
down vote
up vote
1
down vote
request
is a global object which you can access by import
ing request
from flask
:
from flask import request
from app import api
class StaticFiles(Resource):
def get(self):
return(request.base_url)
There are lots of nice alternative formats of the url here, see this answer for more details.
request
is a global object which you can access by import
ing request
from flask
:
from flask import request
from app import api
class StaticFiles(Resource):
def get(self):
return(request.base_url)
There are lots of nice alternative formats of the url here, see this answer for more details.
answered Nov 20 at 9:47
Rob Bricheno
2,280218
2,280218
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of therequest
in the first place!
– Rob Bricheno
Nov 20 at 18:27
add a comment |
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of therequest
in the first place!
– Rob Bricheno
Nov 20 at 18:27
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
ohhh what, Thanks I though request was to be used with only route decorator. What an Idiot I am, I guess it is a thread local object. You wont believe the things I tried.
– Evren Bingøl
Nov 20 at 17:13
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of the
request
in the first place!– Rob Bricheno
Nov 20 at 18:27
@EvrenBingøl No problem, I don't think this is obvious and I also don't think this is a duplicate question as none of the other answers actually tell you how to get a hold of the
request
in the first place!– Rob Bricheno
Nov 20 at 18:27
add a comment |