Load a Pyramid App with Gunicorn in a different path than / - gunicorn

I have a Pyramid application that I am loading with Gunicorn. My ini file has the following:
[app:main]
use = egg:my_example
...
[server:main]
use = egg:gunicorn
host = localhost
port = 5900
workers = 1
worker_class = gevent
I start Gunicorn witn:
gunicorn --paste ./development.ini
So my application is available at http://127.0.0.1:5900
What do I need to to do so my application is available in other path rather than / ,for example at http://127.0.0.1:5900/my_example
I saw the following posts:
pyramid pserve in different root path than /
and Pyramid: how to set SCRIPT_NAME in request.environ but I'm still not able to do it

Rutter is the right answer if you want all the incoming urls to just remove the prefix from them (for example, http://127.0.0.1:5900/my_example/foo/bar navigates to the /foo/bar route in your app). This seems to be what you're describing and the ini snippet in https://stackoverflow.com/a/43506460/704327 should be sufficient. Rutter will also prepare the environment correctly so that your app will generate the correct urls with the /my_example prefix when using request.route_path and request.route_url.

Related

How can we modify the hostingstart.html of kudu in the azure app service?

I'm doing all the work based on the code. I want to work on a simple task of edit and save hostingstart.html in kudu ui, but I don't know how to do it.
Currently, we have checked the connection through Azure app service distribution and dns authentication with terraform, and even checked whether the change is good through hostingstart.html in kuduui.
If possible, I wanted to work with the terraform code, so I wrote it as below and put the html file inside, but it didn't work.
(If it's not terraform, yaml or sh direction is also good.)
resource "azurerm_app_service" "service" {
provider = azurerm.generic
name = "${local.service_name}-service"
app_service_plan_id = azurerm_app_service_plan.service_plan.id
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
https_only = true
source_control {
repo_url = "https://git.a.git"
branch = "master"
}
}
Or can we specify the default path in the internal folder in this way?
tree : web
+page
- hostingstart.html
+terraform
- main.tf
- app_service.tf
site_config {
always_on = true
default_documents = "../page/hostingstart.html"
}
For the moment. It seems best to deploy and apply through blob storage.
(https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_blob)
for Terraform you can’t easily edit that file from management plane APIs, which Terraform would use. Instead, you can deploy a minimal application with whatever you want to show. Here’s an example of deploying code with an ARM template: https://github.com/JasonFreeberg/zip-deploy-arm-template.

How to declare multiple Un-authorized URL's in apache Shiro configuration

I am trying out the Apache Shiro framework and I basically downloaded the setup from a project online. I managed to get it working but I am stuck at a really small issue. I want to make multiple JSF pages in my project to be accessed without any authorization.
The configuration currently looks something like:
authc = org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter
authc.loginUrl = /login.xhtml
roles.unauthorizedUrl = /login.xhtml
Now I would like to add one more page to roles.unnauthorizeddUrl i.e. signUp.xhtml
I tried
roles.unauthorizedUrl = /login.xhtml,/signUp.xhtml
but that doesnt work. Is there a way to declare multiple unauthorized URL's in the config.
The roles.unauthorizedUrl is the Url to which the user has to be redirected in case user tried to access the protected / unauthorized url. So you only add one such URL, otherwise ambiguity will be raised to the framework to which url to redirect.
If you want unprotect any url use the below config in [urls] section
/login.xhtml = anon
/sugnUp.xhtml = anon

Redirect outgoing external asset requests to local filesystem with NodeJS

Let's say we have a request to an S3 bucket to get an image:
<img src="https://s3-us-west-2.amazonaws.com/{BUCKET}/logo.png" />
I need to work on this project without having access to the internet, so within my Express server, I need to find a way to redirect all requests from https://s3-us-west-2.amazonaws.com/{BUCKET} to ~/Desktop/project/{BUCKET}.
Is there a way to do this via proxying, or would it be a better idea to cut a new branch and replace all external asset links with local file locations?
You would have something get something like this in your network panel
"https://s3-us-west-2.amazonaws.com/{BUCKET}/logo.png"
You can basically remove all "http://s3-us-west-2.amazonaws.com"
And lets say you run it on localhost:3000, your request will look like http://localhost:3000/{BUCKET}/logo.png
You can add following lines in your express server.
var request = require('request');
var proxy = true //if running locally else false
app.get('/{BUCKET}/logo.png', function (req,res) {
if (proxy)
res.sendFile('/home/Desktop/project/' + req.url)
else {
var options = {url : 'http://s3-us-west-2.amazonaws.com' +req.url,
method: 'GET'};
req.pipe(request(options)).pipe(res);
}
)}
The problem with this may be that for every asset it requests from s3 it will always go through your express server and the load of getting the assets will come on express server. You can do it for development but it is not recommended for production.
So for the final deploy you can put all the "http://s3-us-west-2.amazonaws.com" again.
If you don't want to do it programmatically, you can use proxy tools like charles or fiddler. They capture all the traffic from your system. You can create rules for particular requests or set of requests to fetch from local instead of s3.

Need to be able to Insert/Delete New Groups in openfire via HTTP or MySQL

I know how to insert a new group via MySQL, and it works, to a degree. The problem is that the database changes are not loaded into memory if you insert the group manually. Sending a HUP signal to the process does work, but it is kludgy and a hack. I desire elegance :)
What I am looking to do, if possible is to make changes (additions/deletions/changes) to a group via MySQL, and then send an HTTP request to the openfire server to read the new changes. Or in the alternative, add/delete/modify groups similar to how the User Service works.
If anyone can help I would appreciate it.
It seems to me that if sending a HUP signal works for you, then that's actually quite a simple, elegant and efficient way to get Openfire to read your new group, particularly if you do it with the following command on the Openfire server (and assuming it's running a Linux/Unix OS):
pkill -f -HUP openfire
If you still want to send an HTTP request to prompt Openfire to re-read the groups, the following Python script should do the job. It is targeted at Openfire 3.8.2, and depends on Python's mechanize library, which in Ubuntu is installed with the python-mechanize package. The script logs into the Openfire server, pulls up the Cache Summary page, selects the Group and Group Metadata Cache options, enables the submit button and then submits the form to clear those two caches.
#!/usr/bin/python
import mechanize
import cookielib
# Customize to suit your setup
of_host = 'http://openfire.server:9090'
of_user = 'admin_username'
of_pass = 'admin_password'
# Initialize browser and cookie jar
br = mechanize.Browser()
br.set_cookiejar(cookielib.LWPCookieJar())
# Log into Openfire server
br.open(of_host + '/login.jsp')
br.select_form('loginForm')
br.form['username'] = of_user
br.form['password'] = of_pass
br.submit()
# Select which cache items to clear in the Cache Summary page
# On my server, 13 is Group and 14 is Group Metadata Cache
br.open(of_host + '/system-cache.jsp')
br.select_form('cacheForm')
br.form['cacheID'] = ['13','14']
# Activate the submit button and submit the form
c = br.form.find_control('clear')
c.readonly = False
c.disabled = False
r = br.submit()
# Uncomment the following line if you want to view results
#print r.read()

How to get custom-resource file after packaging Metro App?

I have a Metro application in which am using different service URLs for receiving the data.For this scenario I want to change service URLs after building my application into a package.I have followed adding resource files into my app as mentioned in MSDN sites and tested by using following code.
var resourceLoader = new Windows.ApplicationModel.Resources.ResourceLoader();
var resourceString = resourceLoader.getString("greeting");
Here am getting greeting resource value string in my app before packaging.After packaging am not able to see my resource files but am able to see default resource files like en-US,fr-FR etc but.
Can anyone suggest some solution to get custom-resource file after packaging?
The way I see it you need to add the resource files before packaging the app... after that's done, you can not additional resources... what you could do is getting the new service url from a service and save it locally as a setting or in your DB
edit: also, resourceLoader.getString("greeting").value; will give you the actual string, or "greeting" in case no resources were found