How to import a file in Flask uWSGI Nginx?












1















I checked every SO question about it, but the answers are mainly on import errors while I do not have such a problem. Mainly I followed this article followed by this one to have a functioning registration.



Instead of using Flask-SQLalchemy I wanted to create my own database (for fun), but when I try to access the database (DButils.py) functions it occurs an internal server error.



The flask code at the top is:



from flask import Flask, render_template, flash, redirect, url_for, session, 
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from functools import wraps
from DButils import *


My folder follows the same order of the git, with DButils.py in the same folder as app.py.



I did not encounter the error when I import the module, but only when I try to call its functions. In DButils.py I have only a signup function:



def signup(nick, email, password):
return True


And when I try to call it in the app.py code like:



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

def register():
form = RegisterForm(request.form)
if request.method == 'POST' and form.validate():
email = form.email.data
nick = form.nick.data
password = form.password.data
signup(nick,email,password) #WHEN COMMENTED NO ERROR OCCURS
return redirect(url_for('login'))
return render_template('register.html', form=form)


I get the message "Internal Server Error" with no other clue about it. What can it be? How can I call a function in an external module in Flask?



Thanks for your help!










share|improve this question

























  • Have you checked Nginx logs? Provide any relevant info from them into this question.

    – Andrejs Cainikovs
    Nov 14 '18 at 10:17













  • Why are you running via nginx when you're still in development, rather than using the built in dev server? And you should start your app with debug on so you can see what the actual error is.

    – Daniel Roseman
    Nov 14 '18 at 10:26











  • Because I am already finished developing in my localhost, where I do not have this issue. I am now trying to migrate into production, but I got this issue that did not present itself in local. The nginx log say '*678 connect() to unix:/home/sammy/myproject/myproject.sock failed (2: No such file or directory)'

    – Mazzespazze
    Nov 14 '18 at 10:28


















1















I checked every SO question about it, but the answers are mainly on import errors while I do not have such a problem. Mainly I followed this article followed by this one to have a functioning registration.



Instead of using Flask-SQLalchemy I wanted to create my own database (for fun), but when I try to access the database (DButils.py) functions it occurs an internal server error.



The flask code at the top is:



from flask import Flask, render_template, flash, redirect, url_for, session, 
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from functools import wraps
from DButils import *


My folder follows the same order of the git, with DButils.py in the same folder as app.py.



I did not encounter the error when I import the module, but only when I try to call its functions. In DButils.py I have only a signup function:



def signup(nick, email, password):
return True


And when I try to call it in the app.py code like:



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

def register():
form = RegisterForm(request.form)
if request.method == 'POST' and form.validate():
email = form.email.data
nick = form.nick.data
password = form.password.data
signup(nick,email,password) #WHEN COMMENTED NO ERROR OCCURS
return redirect(url_for('login'))
return render_template('register.html', form=form)


I get the message "Internal Server Error" with no other clue about it. What can it be? How can I call a function in an external module in Flask?



Thanks for your help!










share|improve this question

























  • Have you checked Nginx logs? Provide any relevant info from them into this question.

    – Andrejs Cainikovs
    Nov 14 '18 at 10:17













  • Why are you running via nginx when you're still in development, rather than using the built in dev server? And you should start your app with debug on so you can see what the actual error is.

    – Daniel Roseman
    Nov 14 '18 at 10:26











  • Because I am already finished developing in my localhost, where I do not have this issue. I am now trying to migrate into production, but I got this issue that did not present itself in local. The nginx log say '*678 connect() to unix:/home/sammy/myproject/myproject.sock failed (2: No such file or directory)'

    – Mazzespazze
    Nov 14 '18 at 10:28
















1












1








1








I checked every SO question about it, but the answers are mainly on import errors while I do not have such a problem. Mainly I followed this article followed by this one to have a functioning registration.



Instead of using Flask-SQLalchemy I wanted to create my own database (for fun), but when I try to access the database (DButils.py) functions it occurs an internal server error.



The flask code at the top is:



from flask import Flask, render_template, flash, redirect, url_for, session, 
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from functools import wraps
from DButils import *


My folder follows the same order of the git, with DButils.py in the same folder as app.py.



I did not encounter the error when I import the module, but only when I try to call its functions. In DButils.py I have only a signup function:



def signup(nick, email, password):
return True


And when I try to call it in the app.py code like:



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

def register():
form = RegisterForm(request.form)
if request.method == 'POST' and form.validate():
email = form.email.data
nick = form.nick.data
password = form.password.data
signup(nick,email,password) #WHEN COMMENTED NO ERROR OCCURS
return redirect(url_for('login'))
return render_template('register.html', form=form)


I get the message "Internal Server Error" with no other clue about it. What can it be? How can I call a function in an external module in Flask?



Thanks for your help!










share|improve this question
















I checked every SO question about it, but the answers are mainly on import errors while I do not have such a problem. Mainly I followed this article followed by this one to have a functioning registration.



Instead of using Flask-SQLalchemy I wanted to create my own database (for fun), but when I try to access the database (DButils.py) functions it occurs an internal server error.



The flask code at the top is:



from flask import Flask, render_template, flash, redirect, url_for, session, 
from wtforms import Form, StringField, TextAreaField, PasswordField, validators
from functools import wraps
from DButils import *


My folder follows the same order of the git, with DButils.py in the same folder as app.py.



I did not encounter the error when I import the module, but only when I try to call its functions. In DButils.py I have only a signup function:



def signup(nick, email, password):
return True


And when I try to call it in the app.py code like:



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

def register():
form = RegisterForm(request.form)
if request.method == 'POST' and form.validate():
email = form.email.data
nick = form.nick.data
password = form.password.data
signup(nick,email,password) #WHEN COMMENTED NO ERROR OCCURS
return redirect(url_for('login'))
return render_template('register.html', form=form)


I get the message "Internal Server Error" with no other clue about it. What can it be? How can I call a function in an external module in Flask?



Thanks for your help!







python nginx flask uwsgi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 10:22









Andrejs Cainikovs

18.4k25373




18.4k25373










asked Nov 14 '18 at 10:14









MazzespazzeMazzespazze

44




44













  • Have you checked Nginx logs? Provide any relevant info from them into this question.

    – Andrejs Cainikovs
    Nov 14 '18 at 10:17













  • Why are you running via nginx when you're still in development, rather than using the built in dev server? And you should start your app with debug on so you can see what the actual error is.

    – Daniel Roseman
    Nov 14 '18 at 10:26











  • Because I am already finished developing in my localhost, where I do not have this issue. I am now trying to migrate into production, but I got this issue that did not present itself in local. The nginx log say '*678 connect() to unix:/home/sammy/myproject/myproject.sock failed (2: No such file or directory)'

    – Mazzespazze
    Nov 14 '18 at 10:28





















  • Have you checked Nginx logs? Provide any relevant info from them into this question.

    – Andrejs Cainikovs
    Nov 14 '18 at 10:17













  • Why are you running via nginx when you're still in development, rather than using the built in dev server? And you should start your app with debug on so you can see what the actual error is.

    – Daniel Roseman
    Nov 14 '18 at 10:26











  • Because I am already finished developing in my localhost, where I do not have this issue. I am now trying to migrate into production, but I got this issue that did not present itself in local. The nginx log say '*678 connect() to unix:/home/sammy/myproject/myproject.sock failed (2: No such file or directory)'

    – Mazzespazze
    Nov 14 '18 at 10:28



















Have you checked Nginx logs? Provide any relevant info from them into this question.

– Andrejs Cainikovs
Nov 14 '18 at 10:17







Have you checked Nginx logs? Provide any relevant info from them into this question.

– Andrejs Cainikovs
Nov 14 '18 at 10:17















Why are you running via nginx when you're still in development, rather than using the built in dev server? And you should start your app with debug on so you can see what the actual error is.

– Daniel Roseman
Nov 14 '18 at 10:26





Why are you running via nginx when you're still in development, rather than using the built in dev server? And you should start your app with debug on so you can see what the actual error is.

– Daniel Roseman
Nov 14 '18 at 10:26













Because I am already finished developing in my localhost, where I do not have this issue. I am now trying to migrate into production, but I got this issue that did not present itself in local. The nginx log say '*678 connect() to unix:/home/sammy/myproject/myproject.sock failed (2: No such file or directory)'

– Mazzespazze
Nov 14 '18 at 10:28







Because I am already finished developing in my localhost, where I do not have this issue. I am now trying to migrate into production, but I got this issue that did not present itself in local. The nginx log say '*678 connect() to unix:/home/sammy/myproject/myproject.sock failed (2: No such file or directory)'

– Mazzespazze
Nov 14 '18 at 10:28














1 Answer
1






active

oldest

votes


















0














I found the answer by an trial-error approach. Apparently using pkill --signal SIGHUP uwsgi in combination with sudo systemctl restart nginx.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53297724%2fhow-to-import-a-file-in-flask-uwsgi-nginx%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I found the answer by an trial-error approach. Apparently using pkill --signal SIGHUP uwsgi in combination with sudo systemctl restart nginx.






    share|improve this answer




























      0














      I found the answer by an trial-error approach. Apparently using pkill --signal SIGHUP uwsgi in combination with sudo systemctl restart nginx.






      share|improve this answer


























        0












        0








        0







        I found the answer by an trial-error approach. Apparently using pkill --signal SIGHUP uwsgi in combination with sudo systemctl restart nginx.






        share|improve this answer













        I found the answer by an trial-error approach. Apparently using pkill --signal SIGHUP uwsgi in combination with sudo systemctl restart nginx.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 10:59









        MazzespazzeMazzespazze

        44




        44






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53297724%2fhow-to-import-a-file-in-flask-uwsgi-nginx%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine