Friday, May 13, 2022

FIX Method not allowed 405 Error in Flask [ Solved ]

Method not allowed 405 Error in Flask resolved

Your routes are correct? Your methods are correct?

None of the stackoverflow solutions work? You still get the Method not allowed 405 Error?

This is the solution!

I was struggling posting a simple form, I had a route that inserted it into the mongo database and then a return redirect to move the user along.

Everything was correct, I had specified methods=['POST], used the correct route and url_for in the template.. but when I posted and got redirected I still got the error "The method is not allowed for the requested URL"

I was searching for a solution for days, but none of the suggestions applied in my case. Everything was correct with the code.

Solution:

Remove the virtual environment and reinstall the dependencies!
For example on a Linux system:

Delete your current virtual environment (assuming the folder is called "env"):

rm -rf env 

Create a new environment:

python3 -m venv env

Source the new environment:

source env/bin/activate

Install your dependencies again:

pip install flask 

That's it!

Or you can try to just re-install flask in your original environment:

pip uninstall flask

pip install flask

Let me know if this simpler step works, and we can recommend that instead. 

 

 

 


Sunday, November 10, 2013

Getting Citrix to work in FIrefox on Ubuntu 13.10

I had trouble getting Citrix to work (with Citrix Reciever) in Firefox on Ubuntu 13.10.

I got error message "SSL Error 61: You have not chosen to trust VeriSign Class 3 Public Primary Certification Authority -G5, the issuer of the server’s security certificate."

As the VeriSign Class 3 Public Primary Certification Authority -G5 certificate is already trusted in Firefox the fix for this was a simple as a symlinc to share Firefox's certificates with Citrix:

sudo ln -s /usr/share/ca-certificates/mozilla/* /opt/Citrix/ICAClient/keystore/cacerts

Saturday, April 21, 2012

Fix: Error "Blank line" installing Lexmark printer driver on Ubuntu 12.04

The following error occured when I tried to install Lexmarks 2600 Series driver from Lexmark's  site and their package Printer Driver for Debian Package Manager based distros.

dpkg: error processing lexmark-inkjet-08-driver-1.0-1.i386.deb (--install):
parsing file '/var/lib/dpkg/tmp.ci/control' near line 9 package 'lexmark-inkjet-08-driver':
blank line in value of field 'Description'
Errors were encountered while processing:
lexmark-inkjet-08-driver-1.0-1.i386.deb


I'm using Ubuntu 12.04 but the process should be similar on other versions too. Turns out it's just a parsing error in the deb file, this is how I fixed it:

Downloaded the lexmark-inkjet-08-driver-1.0-1.i386.deb.sh.zip and extracted the lexmark-inkjet-08-driver-1.0-1.i386.deb.sh file in a directory called lexmark

Extract the contents of the sh file into a folder called lexmark_install
./lexmark-inkjet-08-driver-1.0-1.i386.deb.sh --noexec --target lexmark_install


cd lexmark_install

Untar the file called instaarchive_all
tar -xvvf instarchive_all --lzma

Bring out control.tar.gz from the deb package:
ar x lexmark-inkjet-08-driver-1.0-1.i386.deb control.tar.gz

Untar control.tar.gz
tar xf control.tar.gz

Edit the file control (for example with gedit)
gedit control

It will look similar to this:
Package: lexmark-inkjet-08-driver
Version: 1.0-1
Section: non-free
Priority: optional
Architecture: i386
Installed-Size:
Maintainer: build <build@linux>
Description:
Lexmark Z2300/X2600 Drivers Package

This package contains the Lexmark Z2300/X2600 Drivers. This is

a copyrighted package, please refer to the copyright notice
for details about using this product.

The problem is the blank lines in description, I just removed most of it making it look like this:
Package: lexmark-inkjet-08-driver
Version: 1.0-1
Section: non-free
Priority: optional
Architecture: i386
Installed-Size:
Maintainer: build <build@linux>
Description: Lexmark Z2300/X2600 Drivers Package


Then, add the files back to control.tar.gz
tar cfz control.tar.gz ./control ./postinst ./prerm ./preinst

Add control.tar.gz back to the deb file:
ar r lexmark-inkjet-08-driver-1.0-1.i386.deb control.tar.gz

And finally, install the deb
sudo dpkg --install lexmark-inkjet-08-driver-1.0-1.i386.deb

This is it! If it works your done!

http://archbird.se/lexmark_printer_driver.php

Sunday, November 20, 2011

Repair broken filesystem on Ubuntu

I recently encountered a problem with my laptop running Ubuntu 11.04. Grub got corrupted and apperently the file system too. All I got when booting was a Busybox shell. Luckily I came across this solution.
  1. Boot a Ubuntu Live cd (or in my case a USB stick, created with Unetbootin) 
  2. Run chfsk -v /dev/sdx (where sdx is your broken partition) 
  3. Just answer yes on all the questions that comes up, and reboot! It fixed my problem.

Thursday, September 23, 2010

JavaScript: Switch values in form fields

I have two text fields in a form - "foo" and "bar", and I wanted to add a button to easily switch the values, so that "foo" becomes "bar" and vice versa. This is my JavaScript approach on how to do this:

function switchas() {
var oldFoo = document.getElementById('foo');
var oldBar = document.getElementById('bar');
oldFoo = oldFoo.value;
oldBar = oldBar.value;
document.myForm.elements["foo"].value = oldFoo;
document.myForm.elements["bar"].value = oldBar;
// Uncomment following line for autosubmit
// document.myForm.submit();
}

And the HTML looking like this:

<a href="#" onclick="switchas();">Switch</a>
<form action="#" method="post" name="myForm">
<input id="foo" name="foo" value="foo" type="text">
<input id="bar" name="bar" value="bar" type="text">
</form>

BankID on Ubuntu causes Firefox to freeze

I just installed Swedish BankID on Ubuntu 10.04, after that everey time I start firefox it freezes.
After a quick trip on google i found the sulotion in this thread.
All you need to do is to remove the libP11.so library in /usr/local/lib/personal/ aswell as installing the package libp11-1.
rm /usr/local/lib/personal/libP11.so
apt-get install libp11-1
After that it should work.

Wednesday, September 22, 2010

Howto: Run Tibia in wine

If you for some reason want to run Tibia in wine instead of the native Linux client. (For me it's way faster in wine) - you might find the graphics to be fairly screwed up. To fix this you need to start Tibia with a different graphic engine. There are 3 options available DirectX5, DirectX9 and OpenGL. These are named engine 0, engine 1 and engine 2. You probably want to use OpenGL, so to start tibia, open up your console and run:
wine /home/username/.wine/drive-c/Program\ Files/Tibia/Tibia.exe engine 2
(You might want to try all engines to see wich one is better for you)
Now you can make a launcher to always launch Tibia with the correct engine. I will post about this later.