Skip to content

kerem212012/anime_restaurant

Repository files navigation

🤞&👊 DOMAIN&PUNCH - ANIME RESTAURANT

The site allows order or come to our restaurant and eat special food. Foods are unique you cant find this in another restaurant.


📌 Main features

  • ✅ User registration and authorization
  • ✅ Unique login
  • ✅ Menu with categories
  • ✅ Saving orders in the database
  • ✅ Food and Merch details
  • ✅ Footer with information about the author on all pages

⚙️ Environment variables

The project uses the environs library and reads settings from the .env file, which must be located in the root of the project.

Example file .env:

SECRET_KEY=your_secret_key
ALLOWED_HOSTS = [hosts]
DEBUG = True or False

Variables used:

Variable Purpose
SECRET_KEY Flask Secret Key
ALLOWED_HOSTS It ensures your Django app only responds to requests from trusted domains. "*" is all
DEBUG Controls whether the app is in development or production mode

🐍 Virtual environment (venv)

It is recommended to use venv to isolate project dependencies.

Creating an Environment:

python -m venv venv

Activation:

  • Windows:
source venv\Scripts\activate
  • Mac/Linux:
source venv/bin/activate

🚀 Project launch

  1. Clone the repository:
git clone https://github.com/kerem212012/anime_restaurant.git
cd anime_restaurant
  1. Create and activate a virtual environment (see above)

  2. Install dependencies:

pip install -r requirements.txt
  1. Create a .env file in the root of the project and specify the variables (SECRET_KEY, DEBUG, ALLOWED_HOSTS)

  2. Migrate project and create superuser:

python manage.py makemigration
python manage.py migrate
python manage.py createsuperuser
  1. Start the server:
python manage.py runserver
  1. Go to the browser:

http://127.0.0.1:8000


📄 Project pages

URL name
/ Home page
/register New user registration
/login Login
/logout Logout
/contact About as
/shop Sell food and merch
/product/id Product details

🎯 Project goal

The site was created for money making(fake)

📲 Deploying to internet

💳 Buy site

You need buy site from services I prefer TimeWeb Cloud

🚶‍➡️ Enter to your site

You need git bash, open git bash and print ssh 'your ip' then he asks yes or no say yes. Then give him password of site. After enter write reboot. Open .ssh file open file config in notebook. And write:

Host 'name'
    HostName 'your ip'
    User root

Now you can enter your server like ssh 'name'.

📑 Copying project

In your site(in git bash) you need come to opt file. For this you need do:

cd ..
cd opt/

After it, you need copy project. Example:

git clone https://github.com/kerem212012/anime_restaurant.git

👹 Add Daemon

Install gunicorn to do it enter to your project in bash from opt add venv:

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Now installing gunicorn:

apt update
pip install gunicorn

Now to add daemon we need go to system file:

cd ..
cd ..
cd /etc/systemd/system

We need add file we can do it with nano:

nano name.service

In this file add:

[Unit]
Description=Gunicorn instance for project_name
After=network.target

[Service]
WorkingDirectory=/opt/project_name
Environment="PATH=/opt/project_name/venv/bin"
ExecStart=/opt/project_name/venv/bin/gunicorn --workers 3 --bind unix:/opt/project_name/app_name.sock app_name.wsgi:application

[Install]
WantedBy=multi-user.target

Then lets start it:

systemctl start name.service
systemctl status name.service

Now let's add nginx:

apt install nginx
cd /etc/nginx/sites-available
nano deafult

Delete all and write this if you want with ip:

server {
    listen 80;
    server_name your ip;

    location /static/ {
        root /opt/project_name/staticfiles/;
    }

        location /media/ {
        alias /opt/project_name/media/;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/opt/project_name/app_name.sock;
    }
}

If with domain buy domain like example.ru:

server {
    listen 80;
    server_name name.ru www.name.ru;

    location /static/ {
        alias /opt/project_name/staticfiles/;
    }

    location /media/ {
        alias /opt/project_name/media/;
    }

    location / {
        proxy_pass http://unix:/opt/project_name/app_name.sock;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
apt install certbot python3-certbot-nginx
certbot --nginx -d name.ru -d www.name.ru

Add CSRF_TRUSTED_ORIGINS = env.list("CSRF_TRUSTED_ORIGINS") in settings.py and add CSRF_TRUSTED_ORIGINS = http://name.ru, https://name.ruto .env.

SUBSCRIBE

Chipsinka

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors