Jump to content

heirloom

Members
  • Posts

    20
  • Joined

Everything posted by heirloom

  1. I'm not capable of uploading a website without SSH and I'm not planning on donating until I have the website up and running without problem for at least a month. What can I do?
  2. Hello, my account has been archived even though I logged into it this month: The last time you logged in was 2020-12-01 Please unarchive it Username: heirloom
  3. Nice, it's good to know that I can run flask from the web root. That's not what I'm asking though. I want to keep flask in the subdirectory. But the routes of my app don't take into account that subdirectory so I need a way to append '/flask/' to all routes without actually having to change them one by one in the code.
  4. With my current configuration apache won't read the .htaccess file in the folder /home/username/public_html/flask. First I have to setup apache to read from that folder. How do I do that?
  5. I have an app with static paths like this: import sys import platform from flask import Flask, __version__ app = Flask(__name__) @app.route("/") def hello(): return """ Hello World!<br><br> <a href="/info/">System Information</a> """ @app.route("/info/") def info(): return f""" Platform: {platform.platform()}<br> Python version {sys.version}<br> Flask version: {__version__} """ if __name__ == "__main__": app.run()But when I use it in heliohost the links have to be prefixed with '/flask/'. Is there a way to do this without having to change all the links in the application?
  6. How do I set up the public_html/flask folder?
  7. In the WSGIScriptAlias the alias should be '/' or else all links inside the application will have to include '/flask/path' and changing all the links in the application is not easy unless you've made them relative to a specific url that you can easily change. This has be done for heliohost anyway. This problem has an answer in Path configuration problem with mod_wsgi - WSGIScriptAlias The way in which the Tommy server is configured is probably using the technique explained there.
  8. Actually the installed mod_wsgi was using Python 2.7. So I need a way to install the correct version of mod_wsgi. After installing the correct version of mod_wsgi I no longer have to include the location of the packages. mod_wsgi is now using the default Python3 which is 3.6.8. I couldn't get it to run with 3.7.4, even when installing it with --enable-shared it gave 'Error while loading shared libraries' unless I specified the location of the packages in the code like: import site site.addsitedir('/usr/local/lib/python3.7/site-packages') site.addsitedir('/usr/local/lib64/python3.7/site-packages')Install mod_wsgi 4.6.7 with python 3.7.4 in CentOs 7
  9. I've had some trouble configuring the 'flask' folder. I don't know why I've had to include the location of the python packages in the wsgi file. Or else it said: Exception occurred processing WSGI script '/var/www/flask/myapp.wsgi'. Traceback (most recent call last): File "/var/www/flask/myapp.wsgi", line 6, in <module> from myapp import app as application File "/var/www/flask/myapp/__init__.py", line 1, in <module> from flask import Flask ImportError: No module named flaskAlso although I've installed python 3.7.4 I had to end up using the default Python 3, which is 3.6.8, because I didn't know how to use pip without installing the default. And I couldn't install mod_wsgi from source because it gave me an error, that was something like: 'apxs command not found'. Probably I forgot some dependency. Here I write all the commands I used to deploy flask apps with apache in centos in a similar way as how the Tommy server does it: # VirtualBox guest additions sudo yum install -y epel-release centos-release-scl sudo yum update -y sudo yum install -y make gcc kernel-headers kernel-devel perl dkms bzip2 # Devices -> Insert Guest Additions CD image and run it sudo reboot sudo yum install -y dconf-editor bash <(curl -s https://raw.githubusercontent.com/ajr-dev/post-install-script/master/install/settings/gnome.sh) # Install apache sudo yum install -y httpd httpd-devel python3 python3-pip python3-devel sudo systemctl start httpd sudo systemctl enable httpd # Install mod_wsgi 4.6.7 wget -q "https://github.com/GrahamDumpleton/mod_wsgi/archive/4.6.7.tar.gz" tar -xzf '4.6.7.tar.gz' rm '4.6.7.tar.gz' cd 'mod_wsgi-4.6.7' ./configure --with-python=/usr/local/bin/python3 make sudo make install # Add this to `/etc/httpd/conf/httpd.conf` # LoadModule wsgi_module modules/mod_wsgi.so apachectl restart sudo cat /var/log/httpd/error_log # If all is okay, you should see a line of the form: # Apache/2.4.6 (CentOS) mod_wsgi/4.6.7 Python/3.6 configured cd .. sudo rm -rf 'mod_wsgi-4.6.7' apachectl restart # Flask Deploy with Apache on CentOS sudo pip3 install flask==1.1.1 cd /var/www sudo mkdir flask cd flask sudo mkdir website sudo vi __init__.py from flask import Flask app = Flask(__name__) sudo vi main.py import sys import platform from website import app def linux_distribution(): try: return platform.linux_distribution() except: return "N/A" @app.route("/") def hello(): return """ Hello World!<br><br> <a href="/flask/info/">System Information</a><br> """ @app.route("/info/") def info(): return f""" Python version: {sys.version}<br> dist: {platform.dist()}<br> linux_distribution: {linux_distribution()}<br> system: {platform.system()}<br> machine: {platform.machine()}<br> platform: {platform.platform()}<br> uname: {platform.uname()}<br> """" if __name__ == "__main__": app.run(debug=True)sudo vi website.wsgi import sys sys.path.insert(0, '/var/www/flask') from website import main, app as applicationcd /etc/httpd/conf/ sudo cp httpd.conf httpd.conf.bak sudo vi httpd.conf Insert: <VirtualHost *:80> ServerName localhost WSGIScriptAlias /flask /var/www/flask/website.wsgi <Directory /var/www/flask> Require all granted </Directory> </VirtualHost>apachectl restart # Get IP hostname -I # When visiting 'http://my_host_ip/flask' you should see 'Hello World!' # If you are getting an error you can see it by doing sudo cat /var/log/httpd/error_log
  10. I'm having trouble debugging the code from a github repository that works on my machine, but I can't make it work on the server. So I would like to make a virtual machine with the same os and applications to be able to debug the code. I'm doing a flask website. What are the applications that Tommy has installed to deal with flask? Which os? How to install wsgi?
  11. Nevermind I see that I already imported the modules when I imported the code. That's not the case with Node.js. @filmegoo: You need to download the modules locally using NPM and then compress the node_modules folder to a zip file and upload it to your Node.js folder. After that, extract the file.
  12. It did install the python packages but it failed to install the node modules. Is npm installed in Tommy? Here is the output: 20200727124103-cron.log
  13. I just want to check a script I want to run to make sure it's ok. I want to cd to the flask folder and then run 'python3 dev.py build' so the script that I've made is: `cronjob1.sh` in `$HOME/cronjobs` folder with execute permissions. #!/bin/bash cd "$HOME/public_html/flask/" /usr/bin/python3.7 dev.py build And then the cronjob would be: $HOME/cronjobs/cronjob1.sh > $HOME/logs/`date +\%Y\%m\%d\%H\%M\%S`-cron.log 2>&1dev.py will install pip requirements and npm modules for the project that I've uploaded to work. You think it's ok like that?
  14. That was it, I could register with the same email as in the forum. Thanks a lot!
  15. Yesterday I tried signing up in a server and when in the password selection page it didn't let me press next to finish. It happened in Tommy, Ricky and Johnny. I used the same username, domain and password for all three: name: heirloom domain: heirloom.heliohost.org I didn't receive any error so I don't know what the problem might be. Thank you.
  16. Edit: Sorry I didn't see my previous post had been escalated I thought it had dissappeared. You can delete this one. I don't think I can delete it. I'd like to reuse the domain I used in a previous account which has been backed up and taken offline due to extended maintenance. I've already asked in discord and when I tried to login again with the new email activation, I received the same message about the account being backed up. sohamb03 from discord told me to ask here for the domain to be released. I've already downloaded the backup server. I want either to use the same domain in another account or better yet use the same domain with the same account, I don't mind if I have to sign up again if you have to delete it. username: heirloom server: Johnny domain: heirloom.heliohost.org
  17. heirloom Johnny heirloom.heliohost.org I'd like to be able to use the same domain, can you release it from that account? Or delete the account so I can create the same account and domain name. I've already downloaded the backup.
  18. I think it's 2.7. It's the one that is called when doing /usr/bin/python in cronjob. And in the file I have written #!/usr/bin/env python
  19. I could use the rest of modules by copying them to a folder but it's not working for this. So if you can install python-mysqldb. Server: johnny User: heirloom Thanks.
  20. I need a step by step tutorial on how to run a Python script as cron job with all the things that have to be done in preparation and all the paths with a example script. I'd like the script to work in a directory different than the public one if possible. /home/heirloom/database/main.py.The first line of the python file is #!/usr/bin/env python. Is it correct? And the permissions 755. Where do I see that I actually have python in johnny? Also when I write the cron job for a specific hour the time would be UTC? Try to use this script as an example so I can see if the script actually worked: /home/username/hello.py #!/usr/bin/python with open('hello.text','w+') as f: f.write('Hello server!')cron job to execute the script at 9:15 UTC. It didn't work in my case, I created it at 9:13. 15 9 * * * cd /home/username ; /usr/bin/python hello.pyDo I need a cron job to run the script? I've read perl scripts can be executed by clicking on them.In this web http://www.heliohost.org/classic/features/languages/python what does 'output a Content-type header before anything else' mean. I'm not creating a web with python I just want to print 'Hello' in a file. I've found a tutorial that explains how to run scripts via cron jobs. I followed this tutorial which is exactly the kind of tutorial that there should be in the heliohost wiki. But everything worked fine till the part when it explains how to execute the script in another directory. The problem with executing my script in a public directory is that anyone could be updating the database and I only want to update it once a month because of the overhead. In the tutorial it says: But it doesn't say how to do that. And cPanel doesn't allow me to choose the directory in which to add the handler. Here it says that I have to add the following to httpd.conf (in my case would be): <Directory /home/heirloom/database /> Options +ExecCGI AddHandler cgi-script .py Order allow,deny Allow from all </Directory> But I can't change that file so if an admin could add that to the httpd.conf file. I'd also need around 10 cron jobs a day for testing and when I know how to use it I'm good with one every month.Server: johnny User: heirloom
×
×
  • Create New...